Restructured socials table.
This commit is contained in:
parent
47eb91a7e8
commit
2c58dfe426
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit 1122b4198f2c5bc27f9f4e3f3aedea6c81f09ba1
|
Subproject commit dc00c3d58af2c23530b8b3cb6704f3860fdd7d0f
|
|
@ -0,0 +1,35 @@
|
||||||
|
exports.up = async (knex) => {
|
||||||
|
await knex.schema.alterTable('actors_social', (table) => {
|
||||||
|
table.dropUnique(['url', 'actor_id', 'profile_id']);
|
||||||
|
table.dropColumn('profile_id');
|
||||||
|
|
||||||
|
table.string('username');
|
||||||
|
|
||||||
|
table.unique(['actor_id', 'platform', 'username']);
|
||||||
|
table.unique(['actor_id', 'url']);
|
||||||
|
|
||||||
|
table.datetime('verified_at');
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.raw('ALTER TABLE actors_social ADD CONSTRAINT actors_url_or_username CHECK (num_nulls(username, url) = 1);');
|
||||||
|
await knex.raw('ALTER TABLE actors_social ADD CONSTRAINT actors_username_and_platform CHECK (num_nulls(platform, username) = 2 or num_nulls(platform, username) = 0);');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async (knex) => {
|
||||||
|
await knex.raw('ALTER TABLE actors_social DROP CONSTRAINT actors_url_or_username;');
|
||||||
|
await knex.raw('ALTER TABLE actors_social DROP CONSTRAINT actors_username_and_platform;');
|
||||||
|
|
||||||
|
await knex.schema.alterTable('actors_social', (table) => {
|
||||||
|
table.dropUnique(['actor_id', 'platform', 'username']);
|
||||||
|
table.dropUnique(['actor_id', 'url']);
|
||||||
|
|
||||||
|
table.integer('profile_id')
|
||||||
|
.references('id')
|
||||||
|
.inTable('actors_profiles');
|
||||||
|
|
||||||
|
table.dropColumn('username');
|
||||||
|
table.dropColumn('verified_at');
|
||||||
|
|
||||||
|
table.unique(['url', 'actor_id', 'profile_id']);
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue