20 lines
439 B
JavaScript
20 lines
439 B
JavaScript
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;
|
|
`);
|
|
};
|