/* eslint-disable camelcase */
exports.shorthands = undefined;
exports.up = pgm => {
pgm.createTable('account', {
uuid: {
type: 'uuid',
primaryKey: true,
},
display_name: {
type: 'varchar(50)',
},
email: {
type: 'varchar(50)',
unique: true,
},
password: {
type: 'varchar(200)',
notNull: true
},
nation_code: {
type: 'varchar(10)',
default: '001',
},
mobile: {
type: 'varchar(50)',
unique: true,
},
region: {
type: 'text',
},
avatar: {
type: 'text',
},
info_json: {
type: 'jsonb',
default: '{}',
},
balance: {
type: 'numeric',
default: 0,
},
vip_type: {
type: 'varchar(10)',
},
vip_last_day: {
type: 'date',
},
ctime: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
},
mtime: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
}
})
pgm.createIndex('account', 'email', {
name: 'account_email_idx',
method: 'btree'
})
pgm.createIndex('account', 'mobile', {
name: 'account_mobile_idx',
method: 'btree'
})
};
exports.down = pgm => {
pgm.dropIndex('account', 'email', {
name: 'account_email_idx'
})
pgm.dropIndex('account', 'mobile', {
name: 'account_mobile_idx'
})
pgm.dropTable('account');
};
/* eslint-disable camelcase */
exports.shorthands = undefined;
exports.up = pgm => {
pgm.createTable('dictionary', {
uuid: {
type: 'uuid',
primaryKey: true,
},
word: {
type: 'varchar(50)',
notNull: true
},
property: {
type: 'varchar(10)',
},
explain: {
type: 'varchar(50)',
},
sound: {
type: 'jsonb',
default: '{}',
},
pronounce: {
type: 'jsonb',
default: '{}',
},
difficulty: {
type: 'integer'
},
order: {
type: 'integer',
default: 0,
},
ctime: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
},
mtime: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
}
})
pgm.createIndex('dictionary', 'word', {
name: 'dictionary_word_idx',
method: 'btree'
})
pgm.createIndex('dictionary', 'difficulty', {
name: 'dictionary_difficulty_idx',
method: 'btree'
})
pgm.addConstraint('dictionary', 'dictionary_word_property_explain_unique_constraint', {"unique": ['word', 'property', 'explain']})
};
exports.down = pgm => {
pgm.dropConstraint('dictionary', 'dictionary_word_property_explain_unique_constraint');
pgm.dropIndex('dictionary', 'difficulty', {
name: 'dictionary_difficulty_idx'
})
pgm.dropIndex('dictionary', 'word', {
name: 'dictionary_word_idx'
})
pgm.dropTable('dictionary');
};
/* eslint-disable camelcase */
exports.shorthands = undefined;
exports.up = pgm => {
pgm.createTable('sentence', {
uuid: {
type: 'uuid',
primaryKey: true,
},
word_list: {
type: 'jsonb',
default: '[]',
},
info_json: {
type: 'jsonb',
default: '{}',
},
ctime: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
},
mtime: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp'),
}
})
pgm.createIndex('sentence', 'word_list', {
name: 'sentence_word_list_gin_idx',
method: 'gin'
})
};
exports.down = pgm => {
pgm.dropIndex('sentence', 'word_list', {
name: 'sentence_word_list_gin_idx'
})
pgm.dropTable('sentence');
};