diff --git a/db/migrations/20180302130024_create_messages.js b/db/migrations/20180302130024_create_messages.js new file mode 100644 index 0000000000000000000000000000000000000000..dead1ac7428fb9d313553611c737d0da84b93e47 --- /dev/null +++ b/db/migrations/20180302130024_create_messages.js @@ -0,0 +1,14 @@ + +exports.up = function(knex, Promise) { + return knex.schema.createTable('messages', function (table) { + table.timestamps(true,true); + table.increments('id'); + + table.string('title').notNullable(); + table.text('content'); + }); +}; + +exports.down = function(knex, Promise) { + return knex.schema.dropTable('messages'); +}; diff --git a/db/migrations/20180302130024_create_posts.js b/db/migrations/20180302130024_create_posts.js deleted file mode 100644 index b5d952a8c6bb29006bc6745f11637aab46529682..0000000000000000000000000000000000000000 --- a/db/migrations/20180302130024_create_posts.js +++ /dev/null @@ -1,15 +0,0 @@ - -exports.up = function(knex, Promise) { - return knex.schema.createTable('posts', function (table) { - table.timestamps(true,true); - table.increments('id'); - - table.string('title').notNullable(); - table.text('description'); - table.specificType('authors', knex.raw('varchar(128)[]')).notNullable(); - }); -}; - -exports.down = function(knex, Promise) { - return knex.schema.dropTable('posts'); -}; diff --git a/db/migrations/20180302152113_requests.js b/db/migrations/20180302152113_requests.js index c0c4f45279c09e845facedbcdad6fa4f5fa48d1a..7fa068828355a24885361b81ff8f301954213e7b 100644 --- a/db/migrations/20180302152113_requests.js +++ b/db/migrations/20180302152113_requests.js @@ -1,22 +1,22 @@ exports.up = function(knex, Promise) { - return knex.schema.createTable('request', function (table){ + return knex.schema.createTable('requests', function (table){ table.timestamps(true, true); table.increments('id'); - table.string('recepient').notNullable(); + table.string('recipient').notNullable(); table.text('message'); }).then(()=>{ return knex.schema.createTable('user_join_group', function (table) { - table.inherits('request'); + table.inherits('requests'); table.string('useruid').notNullable(); }).then(()=>{ return knex.schema.createTable('group_join_event', function (table){ - table.inherits('request'); + table.inherits('requests'); table.string('eventuid').notNullable(); table.string('senderuid').notNullable(); }).then(() => { return knex.schema.createTable('your_group_host_event', function(table){ - table.inherits('request'); + table.inherits('requests'); table.string('eventuid').notNullable(); table.string('senderuid').notNullable(); }); @@ -29,7 +29,7 @@ exports.down = function(knex, Promise) { return knex.schema.dropTable('your_group_host_event').then(() => { return knex.schema.dropTable('group_join_event').then(() => { return knex.schema.dropTable('user_join_group').then(() => { - return knex.schema.dropTable('request').then(() => { + return knex.schema.dropTable('requests').then(() => { }); }); }); diff --git a/db/migrations/20180302184519_rename_recipient_user_join_group.js b/db/migrations/20180302184519_rename_recipient_user_join_group.js deleted file mode 100644 index 896d69d4b1a4e4a4495dbbe3242f8534efe0b9c1..0000000000000000000000000000000000000000 --- a/db/migrations/20180302184519_rename_recipient_user_join_group.js +++ /dev/null @@ -1,13 +0,0 @@ - -exports.up = function(knex, Promise) { - return knex.schema.renameTable('request','requests').table('requests', function(table) { - table.renameColumn('recepient','recipient'); - }); -}; - -exports.down = function(knex, Promise) { - return knex.schema.table('requests', function (table) { - table.renameColumn('recipient', 'recepient'); - table.renameColumn('requests','request'); - }); -}; diff --git a/db/migrations/20180303192411_create_metaGroups.js b/db/migrations/20180303192411_create_metaGroups.js index 5888122b6b7911c9378fc7fc77f85bc4f96e188c..03a7ed8b5844dd90d5c6f96264a01f2e65fd4b8c 100644 --- a/db/migrations/20180303192411_create_metaGroups.js +++ b/db/migrations/20180303192411_create_metaGroups.js @@ -1,13 +1,13 @@ /* -Une mutation pour rajouter dans la BDD les types SimpleGroup et MetaGroup +Une migrations pour rajouter dans la BDD les tables simple_group et meta_group (cf la documentation de l'API GraphQL) -Les objets qui étaient jusqu''à présent stoqués dans la table groups +Les objets qui étaient jusqu'à présent stoqués dans la table groups sont déplacés dans la table simple_groups En cas de rollback, le déplacement se fait dans l'autre sens (et les meta groupes sont perdus) -Après cette mutation, plus rien n'est sensé être mis directement dans la table groups +Après cette migration, plus rien n'est sensé être mis directement dans la table groups */ exports.up = function(knex, Promise) { diff --git a/db/migrations/20180307213043_fixes_and_messages.js b/db/migrations/20180307213043_fixes_and_messages.js index 7c46a723b9ad3ae6efb4f501eb215e97dd1b0488..fae3685161e1c52b137ae2a2916e59f5852e3ea5 100644 --- a/db/migrations/20180307213043_fixes_and_messages.js +++ b/db/migrations/20180307213043_fixes_and_messages.js @@ -1,11 +1,9 @@ exports.up = async function(knex, Promise) { - await knex.schema.renameTable("posts", "messages"); - await knex.schema.table('messages', function(table){ - table.renameColumn('description', 'content'); - }); await knex.schema.createTable('announcements', function (table){ table.inherits('messages'); + table.specificType('authors', knex.raw('varchar(128)[]')); + table.integer('views').defaultTo(0); }); await knex.schema.createTable('events', function (table){ table.inherits('messages'); @@ -13,6 +11,7 @@ exports.up = async function(knex, Promise) { table.dateTime('start_time'); table.dateTime('end_time'); table.boolean('is_announcement'); + table.specificType('authors', knex.raw('varchar(128)[]')); }); await knex.schema.createTable('group_message_relationships', function(table){ table.integer('message').notNullable(); @@ -31,14 +30,10 @@ exports.down = async function(knex, Promise) { await knex.schema.dropTable('group_message_relationships'); await knex.schema.dropTable('user_participation'); let event_posts = await knex.select().from('events'); - let announcment_posts = await knex.select().from('announcements'); + let announcement_posts = await knex.select().from('announcements'); await knex.schema.dropTable('events'); await knex.schema.dropTable('announcements'); - await knex.schema.renameTable('messages', 'posts'); - await knex.schema.table('posts', function(table){ - table.renameColumn('content', 'description'); - }); await knex('messages').insert(event_posts); - await knex('messages').insert(announcment_posts); + await knex('messages').insert(announcement_posts); return; }; diff --git a/db/migrations/20180316003119_create_posts_again.js b/db/migrations/20180316003119_create_posts.js similarity index 54% rename from db/migrations/20180316003119_create_posts_again.js rename to db/migrations/20180316003119_create_posts.js index 63783781a6bc3d967808e82fbab37f9d29ce84ff..2e41a8464fb8ecc1c7cf7f29dd0b10f88ce1a506 100644 --- a/db/migrations/20180316003119_create_posts_again.js +++ b/db/migrations/20180316003119_create_posts.js @@ -3,18 +3,11 @@ exports.up = async function(knex, Promise) { await knex.schema.createTable('posts', function(table) { table.inherits('messages'); }); - await knex.schema.table('announcements', function(table) { - table.integer('views').defaultTo(0); - }); return; }; exports.down = async function(knex, Promise) { await knex.schema.dropTable('posts'); - await knex.schema.table("announcements", function(table) { - table.dropColumn('views'); - }); - return; }; diff --git a/db/migrations/20180415160405_message_types.js b/db/migrations/20180415160405_message_types.js index eb33d9b28c1648b7bdf0bcb04e743db5c4c66a5d..cae18304e8099e15d7b6ec117812b9f517b853c9 100644 --- a/db/migrations/20180415160405_message_types.js +++ b/db/migrations/20180415160405_message_types.js @@ -1,9 +1,5 @@ exports.up = async function(knex, Promise) { - await knex.schema.dropTable('posts'); - await knex.schema.table('messages', function(table){ - table.dropColumn('authors'); - }); await knex.schema.createTable('private_post', function(table){ table.inherits('messages'); table.string('author_uid', 128).notNullable(); @@ -22,12 +18,6 @@ exports.up = async function(knex, Promise) { table.string('recipient_uid', 128).notNullable(); table.string('for_question', 128).notNullable(); }); - await knex.schema.table('events', function(table){ - table.specificType('authors', knex.raw('varchar(128)[]')); - }); - await knex.schema.table('announcements', function(table){ - table.specificType('authors', knex.raw('varchar(128)[]')); - }); return; }; @@ -35,11 +25,5 @@ exports.down = async function(knex, Promise) { await knex.schema.dropTable('answer'); await knex.schema.dropTable('question'); await knex.schema.dropTable('private_post'); - await knex.schema.table('messages', function(table){ - table.specificType('authors', knex.raw('varchar(128)[]')); - }); - await knex.schema.createTable('posts', function(table) { - table.inherits('messages'); - }); return; };