From 9cdf4eedd29b14490f4292b65c8ca8d5016e4325 Mon Sep 17 00:00:00 2001 From: rui hildt Date: Fri, 28 Aug 2020 13:10:15 +0200 Subject: [PATCH] Change db structure to allow inviteless accounts --- data/migrations/20200502193341_participant.js | 13 +++---------- data/migrations/20200502193443_availability.js | 13 ++++--------- data/seeds/4 - participants.js | 12 ++++++++++++ ...{5 - availability.js => 5 - availability.js.bak} | 0 4 files changed, 19 insertions(+), 19 deletions(-) rename data/seeds/{5 - availability.js => 5 - availability.js.bak} (100%) diff --git a/data/migrations/20200502193341_participant.js b/data/migrations/20200502193341_participant.js index 5aaa81a..d782800 100644 --- a/data/migrations/20200502193341_participant.js +++ b/data/migrations/20200502193341_participant.js @@ -1,16 +1,9 @@ exports.up = (knex) => { return knex.schema.createTable('participant', (table) => { + table.uuid('id').primary(); table.integer('account_id').unsigned(); - table.uuid('meeting_id').unsigned(); - table - .foreign('meeting_id') - .references('meeting.id') - .onDelete('cascade'); - table - .foreign('account_id') - .references('account.id') - .onDelete('cascade'); - table.primary(['meeting_id', 'account_id']); + table.string('email'); + table.uuid('meeting_id').unsigned().notNullable(); table.boolean('quorum'); table.boolean('mandatory'); table.boolean('host').notNullable(); diff --git a/data/migrations/20200502193443_availability.js b/data/migrations/20200502193443_availability.js index 3b685a4..2edd8fa 100644 --- a/data/migrations/20200502193443_availability.js +++ b/data/migrations/20200502193443_availability.js @@ -1,17 +1,12 @@ exports.up = (knex) => { return knex.schema.createTable('availability', (table) => { table.increments('id').primary(); - - // Reference to participant composite primary key - table.uuid('meeting_id').unsigned(); - table.integer('account_id').unsigned(); + table.uuid('participant_id').notNullable(); table - .foreign(['account_id', 'meeting_id']) - .references(['account_id', 'meeting_id']) - .on('participant') + .foreign('participant_id') + .references('participant.id') .onDelete('cascade'); - - table.integer('possible_date_id'); + table.integer('possible_date_id').notNullable(); table .foreign('possible_date_id') .references('possible_date.id') diff --git a/data/seeds/4 - participants.js b/data/seeds/4 - participants.js index 9667f64..64025fc 100644 --- a/data/seeds/4 - participants.js +++ b/data/seeds/4 - participants.js @@ -6,6 +6,7 @@ exports.seed = function (knex) { // Inserts seed entries return knex('participant').insert([ { + id: '65fda742-e91e-11ea-adc1-0242ac120002', account_id: 1, meeting_id: '03ac7a10-316f-46e8-bb55-8611e7e5b31c', quorum: 0, @@ -14,6 +15,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fda9ae-e91e-11ea-adc1-0242ac120002', account_id: 1, meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', quorum: 0, @@ -22,6 +24,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdaaa8-e91e-11ea-adc1-0242ac120002', account_id: 1, meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c', quorum: 0, @@ -30,6 +33,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdab84-e91e-11ea-adc1-0242ac120002', account_id: 2, meeting_id: '03ac7a10-316f-46e8-bb55-8611e7e5b31c', quorum: 0, @@ -38,6 +42,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdac56-e91e-11ea-adc1-0242ac120002', account_id: 3, meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', quorum: 0, @@ -46,6 +51,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdad1e-e91e-11ea-adc1-0242ac120002', account_id: 4, meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c', quorum: 0, @@ -54,6 +60,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdb066-e91e-11ea-adc1-0242ac120002', account_id: 4, meeting_id: 'aa639e05-be03-4202-a18e-aae3bc5153f0', quorum: 0, @@ -62,6 +69,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdade6-e91e-11ea-adc1-0242ac120002', account_id: 4, meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', quorum: 0, @@ -70,6 +78,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdb12e-e91e-11ea-adc1-0242ac120002', account_id: 5, meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c', quorum: 0, @@ -78,6 +87,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdb1f6-e91e-11ea-adc1-0242ac120002', account_id: 5, meeting_id: 'a4a9b71a-91af-4e35-8377-96f56fa7f6b8', quorum: 0, @@ -86,6 +96,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdb2b4-e91e-11ea-adc1-0242ac120002', account_id: 5, meeting_id: '741f300a-a137-499d-b725-73770ac6fe70', quorum: 0, @@ -94,6 +105,7 @@ exports.seed = function (knex) { answered: 0, }, { + id: '65fdb372-e91e-11ea-adc1-0242ac120002', account_id: 5, meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', quorum: 0, diff --git a/data/seeds/5 - availability.js b/data/seeds/5 - availability.js.bak similarity index 100% rename from data/seeds/5 - availability.js rename to data/seeds/5 - availability.js.bak