exports.up = function (knex, Promise) { return knex.schema.createTable('messages_announcements', function (table) { table.increments('mid'); //autoincrementing (non-nullable) primary key table.timestamps(true, true); //adds timestamptz-type (a PostgresQL data type) updated_at and created_at columns table.string('title').notNullable(); table.text('content'); table.integer('views').defaultTo(0); /* Les auteurs et destinataires des annonces sont dans les tables announcements_authors et announcements_recipients table.string('recipient',128).notNullable().defaultTo('noone') .references('gid').inTable('groups') .onDelete('SET DEFAULT'); //if recipient is deleted, direct to the special "no-one" group //TODO: for now, we support only 1 author (where as graphql schema indicates support for [Group] authors) table.string('author',128).notNullable() .references('gid').inTable('groups') .onDelete('CASCADE'); //delete message if author is deleted */ /* we cannot declare this column yet, as table 'message_events' is not yet created. it will be declared in the migration for the 'message_events' table. table.integer('for_event') .references('mid').inTable('message_events') .onDelete('SET NULL'); */ }); }; exports.down = function (knex, Promise) { return knex.schema.dropTable('messages_announcements'); };