3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-14 21:31:50 +00:00
zeppelin/migrations/20171221220235_create_mod_action_tables.js

31 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-07-01 03:35:51 +03:00
exports.up = async function(knex, Promise) {
await knex.schema.createTableIfNotExists('mod_actions', table => {
table.increments('id');
table.bigInteger('guild_id').unsigned().notNullable();
table.integer('case_number').unsigned().notNullable();
table.bigInteger('user_id').index().unsigned().notNullable();
table.string('user_name', 128).notNullable();
table.bigInteger('mod_id').index().unsigned().nullable().defaultTo(null);
table.string('mod_name', 128).nullable().defaultTo(null);
table.string('action_type', 16).notNullable();
table.bigInteger('audit_log_id').unique().nullable().defaultTo(null);
table.dateTime('created_at').index().defaultTo(knex.raw('NOW()')).notNullable();
table.unique(['guild_id', 'case_number']);
});
await knex.schema.createTableIfNotExists('mod_action_notes', table => {
table.increments('id');
table.integer('mod_action_id').unsigned().notNullable().index().references('id').inTable('mod_actions').onDelete('CASCADE');
table.bigInteger('mod_id').index().unsigned().nullable().defaultTo(null);
table.string('mod_name', 128).nullable().defaultTo(null);
table.text('body').notNullable();
table.dateTime('created_at').index().defaultTo(knex.raw('NOW()')).notNullable();
});
};
exports.down = async function(knex, Promise) {
await knex.schema.dropTableIfExists('mod_action_notes');
await knex.schema.dropTableIfExists('mod_actions');
};