aboutsummaryrefslogtreecommitdiff
path: root/src/api/database/migrations
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-10 01:17:00 +0300
committerGitHub <[email protected]>2020-07-10 01:17:00 +0300
commita721681944e9eb06742e5b3f71c71aed9c1c117d (patch)
tree93ff9fd13a0434d91fb1ae7ca0da48d6929c4d00 /src/api/database/migrations
parentfeat: backend pagination for albums (diff)
parentrefactor: finish refactoring all the components to use vuex (diff)
downloadhost.fuwn.me-a721681944e9eb06742e5b3f71c71aed9c1c117d.tar.xz
host.fuwn.me-a721681944e9eb06742e5b3f71c71aed9c1c117d.zip
Merge pull request #1 from Zephyrrus/feature/store_refactor
Feature/store refactor
Diffstat (limited to 'src/api/database/migrations')
-rw-r--r--src/api/database/migrations/20190221225812_initialMigration.js40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/api/database/migrations/20190221225812_initialMigration.js b/src/api/database/migrations/20190221225812_initialMigration.js
index a27a08a..b755a33 100644
--- a/src/api/database/migrations/20190221225812_initialMigration.js
+++ b/src/api/database/migrations/20190221225812_initialMigration.js
@@ -1,40 +1,44 @@
-exports.up = async knex => {
- await knex.schema.createTable('users', table => {
+exports.up = async (knex) => {
+ await knex.schema.createTable('users', (table) => {
table.increments();
- table.string('username');
+ table.string('username').unique();
table.text('password');
table.boolean('enabled');
table.boolean('isAdmin');
- table.string('apiKey');
+ table.string('apiKey').unique();
table.timestamp('passwordEditedAt');
table.timestamp('apiKeyEditedAt');
table.timestamp('createdAt');
table.timestamp('editedAt');
});
- await knex.schema.createTable('albums', table => {
+ await knex.schema.createTable('albums', (table) => {
table.increments();
table.integer('userId');
table.string('name');
+ table.boolean('nsfw').defaultTo(false);
table.timestamp('zippedAt');
table.timestamp('createdAt');
table.timestamp('editedAt');
+
+ table.unique(['userId', 'name']);
});
- await knex.schema.createTable('files', table => {
+ await knex.schema.createTable('files', (table) => {
table.increments();
table.integer('userId');
table.string('name');
table.string('original');
table.string('type');
table.integer('size');
+ table.boolean('nsfw').defaultTo(false);
table.string('hash');
table.string('ip');
table.timestamp('createdAt');
table.timestamp('editedAt');
});
- await knex.schema.createTable('links', table => {
+ await knex.schema.createTable('links', (table) => {
table.increments();
table.integer('userId');
table.integer('albumId');
@@ -45,42 +49,50 @@ exports.up = async knex => {
table.timestamp('expiresAt');
table.timestamp('createdAt');
table.timestamp('editedAt');
+
+ table.unique(['userId', 'albumId', 'identifier']);
});
- await knex.schema.createTable('albumsFiles', table => {
+ await knex.schema.createTable('albumsFiles', (table) => {
table.increments();
table.integer('albumId');
table.integer('fileId');
+
+ table.unique(['albumId', 'fileId']);
});
- await knex.schema.createTable('albumsLinks', table => {
+ await knex.schema.createTable('albumsLinks', (table) => {
table.increments();
table.integer('albumId');
- table.integer('linkId');
+ table.integer('linkId').unique();
});
- await knex.schema.createTable('tags', table => {
+ await knex.schema.createTable('tags', (table) => {
table.increments();
table.string('uuid');
table.integer('userId');
table.string('name');
table.timestamp('createdAt');
table.timestamp('editedAt');
+
+ table.unique(['userId', 'name']);
});
- await knex.schema.createTable('fileTags', table => {
+ await knex.schema.createTable('fileTags', (table) => {
table.increments();
table.integer('fileId');
table.integer('tagId');
+
+ table.unique(['fileId', 'tagId']);
});
- await knex.schema.createTable('bans', table => {
+ await knex.schema.createTable('bans', (table) => {
table.increments();
table.string('ip');
table.timestamp('createdAt');
});
};
-exports.down = async knex => {
+exports.down = async (knex) => {
await knex.schema.dropTableIfExists('users');
await knex.schema.dropTableIfExists('albums');
await knex.schema.dropTableIfExists('files');