From 68634418e1c86d5ebd5dc2feead241919d3aa9ed Mon Sep 17 00:00:00 2001 From: Pitu Date: Sun, 27 Dec 2020 03:02:14 +0900 Subject: Squashed commit of the following: commit df4b0378571708086a276e49ac8630095e08b0b7 Author: Pitu Date: Sun Dec 27 03:00:17 2020 +0900 feat: move database modification to a new migration file --- .../migrations/20201227023216_addUniques.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/api/database/migrations/20201227023216_addUniques.js (limited to 'src/api/database/migrations/20201227023216_addUniques.js') diff --git a/src/api/database/migrations/20201227023216_addUniques.js b/src/api/database/migrations/20201227023216_addUniques.js new file mode 100644 index 0000000..14f9e7f --- /dev/null +++ b/src/api/database/migrations/20201227023216_addUniques.js @@ -0,0 +1,33 @@ +exports.up = async knex => { + await knex.schema.alterTable('users', table => { + table.unique(['username', 'apiKey']); + }); + + await knex.schema.alterTable('albums', table => { + table.boolean('nsfw').defaultTo(false); + table.unique(['userId', 'name']); + }); + + await knex.schema.alterTable('links', table => { + table.unique(['userId', 'albumId', 'identifier']); + }); + + await knex.schema.alterTable('albumsFiles', table => { + table.unique(['albumId', 'fileId']); + }); + + await knex.schema.alterTable('albumsLinks', table => { + table.unique(['linkId']); + }); + + await knex.schema.alterTable('tags', table => { + table.unique(['userId', 'name']); + }); + + await knex.schema.alterTable('fileTags', table => { + table.unique(['fileId', 'tagId']); + }); +}; +exports.down = async knex => { + // Nothing +}; -- cgit v1.2.3