Change db structure to allow inviteless accounts

This commit is contained in:
rui hildt 2020-08-28 13:10:15 +02:00
parent 38f3c06d51
commit 9cdf4eedd2
4 changed files with 19 additions and 19 deletions

View File

@ -1,16 +1,9 @@
exports.up = (knex) => { exports.up = (knex) => {
return knex.schema.createTable('participant', (table) => { return knex.schema.createTable('participant', (table) => {
table.uuid('id').primary();
table.integer('account_id').unsigned(); table.integer('account_id').unsigned();
table.uuid('meeting_id').unsigned(); table.string('email');
table table.uuid('meeting_id').unsigned().notNullable();
.foreign('meeting_id')
.references('meeting.id')
.onDelete('cascade');
table
.foreign('account_id')
.references('account.id')
.onDelete('cascade');
table.primary(['meeting_id', 'account_id']);
table.boolean('quorum'); table.boolean('quorum');
table.boolean('mandatory'); table.boolean('mandatory');
table.boolean('host').notNullable(); table.boolean('host').notNullable();

View File

@ -1,17 +1,12 @@
exports.up = (knex) => { exports.up = (knex) => {
return knex.schema.createTable('availability', (table) => { return knex.schema.createTable('availability', (table) => {
table.increments('id').primary(); table.increments('id').primary();
table.uuid('participant_id').notNullable();
// Reference to participant composite primary key
table.uuid('meeting_id').unsigned();
table.integer('account_id').unsigned();
table table
.foreign(['account_id', 'meeting_id']) .foreign('participant_id')
.references(['account_id', 'meeting_id']) .references('participant.id')
.on('participant')
.onDelete('cascade'); .onDelete('cascade');
table.integer('possible_date_id').notNullable();
table.integer('possible_date_id');
table table
.foreign('possible_date_id') .foreign('possible_date_id')
.references('possible_date.id') .references('possible_date.id')

View File

@ -6,6 +6,7 @@ exports.seed = function (knex) {
// Inserts seed entries // Inserts seed entries
return knex('participant').insert([ return knex('participant').insert([
{ {
id: '65fda742-e91e-11ea-adc1-0242ac120002',
account_id: 1, account_id: 1,
meeting_id: '03ac7a10-316f-46e8-bb55-8611e7e5b31c', meeting_id: '03ac7a10-316f-46e8-bb55-8611e7e5b31c',
quorum: 0, quorum: 0,
@ -14,6 +15,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fda9ae-e91e-11ea-adc1-0242ac120002',
account_id: 1, account_id: 1,
meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634',
quorum: 0, quorum: 0,
@ -22,6 +24,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdaaa8-e91e-11ea-adc1-0242ac120002',
account_id: 1, account_id: 1,
meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c', meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c',
quorum: 0, quorum: 0,
@ -30,6 +33,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdab84-e91e-11ea-adc1-0242ac120002',
account_id: 2, account_id: 2,
meeting_id: '03ac7a10-316f-46e8-bb55-8611e7e5b31c', meeting_id: '03ac7a10-316f-46e8-bb55-8611e7e5b31c',
quorum: 0, quorum: 0,
@ -38,6 +42,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdac56-e91e-11ea-adc1-0242ac120002',
account_id: 3, account_id: 3,
meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634',
quorum: 0, quorum: 0,
@ -46,6 +51,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdad1e-e91e-11ea-adc1-0242ac120002',
account_id: 4, account_id: 4,
meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c', meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c',
quorum: 0, quorum: 0,
@ -54,6 +60,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdb066-e91e-11ea-adc1-0242ac120002',
account_id: 4, account_id: 4,
meeting_id: 'aa639e05-be03-4202-a18e-aae3bc5153f0', meeting_id: 'aa639e05-be03-4202-a18e-aae3bc5153f0',
quorum: 0, quorum: 0,
@ -62,6 +69,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdade6-e91e-11ea-adc1-0242ac120002',
account_id: 4, account_id: 4,
meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634',
quorum: 0, quorum: 0,
@ -70,6 +78,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdb12e-e91e-11ea-adc1-0242ac120002',
account_id: 5, account_id: 5,
meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c', meeting_id: 'a8344a68-7961-4bff-bb3b-b288f3abcf1c',
quorum: 0, quorum: 0,
@ -78,6 +87,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdb1f6-e91e-11ea-adc1-0242ac120002',
account_id: 5, account_id: 5,
meeting_id: 'a4a9b71a-91af-4e35-8377-96f56fa7f6b8', meeting_id: 'a4a9b71a-91af-4e35-8377-96f56fa7f6b8',
quorum: 0, quorum: 0,
@ -86,6 +96,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdb2b4-e91e-11ea-adc1-0242ac120002',
account_id: 5, account_id: 5,
meeting_id: '741f300a-a137-499d-b725-73770ac6fe70', meeting_id: '741f300a-a137-499d-b725-73770ac6fe70',
quorum: 0, quorum: 0,
@ -94,6 +105,7 @@ exports.seed = function (knex) {
answered: 0, answered: 0,
}, },
{ {
id: '65fdb372-e91e-11ea-adc1-0242ac120002',
account_id: 5, account_id: 5,
meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634', meeting_id: '2e8f3748-ea5a-4d20-b9a8-683ac65f5634',
quorum: 0, quorum: 0,