traxxx/migrations/20230607231459_stash_unique.js

20 lines
439 B
JavaScript
Raw Normal View History

2023-06-07 23:16:44 +00:00
exports.up = async (knex) => {
await knex.schema.alterTable('stashes', (table) => {
table.unique(['user_id', 'slug']);
});
await knex.raw(`
CREATE UNIQUE INDEX unique_primary ON stashes (user_id, "primary") WHERE ("primary" = TRUE);
`);
};
exports.down = async (knex) => {
await knex.schema.alterTable('stashes', (table) => {
table.dropUnique(['user_id', 'slug']);
});
await knex.raw(`
DROP INDEX unique_primary;
`);
};