aboutsummaryrefslogtreecommitdiff
path: root/src/api/database/migrations/20201227023216_addUniques.js
blob: 14f9e7f2be66a33e9187ba76a7176d69c57907f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
};