| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- exports.up = function(knex) {
- return knex.schema
- .createTable('users', function(table) {
- table.increments('user_id').primary()
- table.string('user_name', 32).notNullable()
- table.string('user_email', 90).notNullable()
- table.timestamps(false, true) // Precision to the second
- })
- .createTable('accounts', function(table) {
- table.increments('account_id').primary()
- table.integer('user_id').notNullable()
- table.timestamps(false, true) // Precision to the second
- })
- .createTable('logins', function(table) {
- table.increments('login_id').primary()
- table.integer('account_id').notNullable()
- table.string('login_email', 90).notNullable()
- table.string('login_password', 128).notNullable()
- table.timestamps(false, true) // Precision to the second
- })
- .createTable('profiles', function(table) {
- table.increments('profile_id').primary()
- table.integer('account_id').notNullable()
- table.string('profile_name', 128).notNullable()
- table.json('profile_data').notNullable()
- table.timestamps(false, true) // Precision to the second
- })
- .createTable('groupings', function(table) {
- table.increments('grouping_id').primary()
- table.string('grouping_name', 128).notNullable()
- table.string('grouping_type', 128).notNullable() // Don't over normalize
- table.timestamps(false, true) // Precision to the second
- })
- .createTable('memberships', function(table) {
- table.increments('membership_id').primary()
- table.integer('account_id').notNullable() // From
- table.integer('group_id').notNullable() // To
- table.string('membership_type', 128).notNullable() // Don't over normalize
- table.string('membership_role', 128).notNullable() // Don't over normalize
- })
- .createTable('chats', function(table) {
- table.increments('chat_id').primary()
- table.integer('membership_id').notNullable()
- table.timestamps(false, true) // Precision to the second
- })
- .createTable('messages', function(table) {
- table.increments('message_id').primary()
- table.integer('chat_id').notNullable()
- table.integer('message_account_id').notNullable()
- table.string('message', 255).notNullable()
- })
- }
-
- exports.down = function(knex) {
- return knex.schema
- .dropTable('users')
- .dropTable('accounts')
- .dropTable('logins')
- .dropTable('profiles')
- .dropTable('memberships')
- .dropTable('groupings')
- .dropTable('chats')
- .dropTable('messages')
- }
|