|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+exports.up = function(knex) {
|
|
|
2
|
+ return knex.schema
|
|
|
3
|
+ .createTable('users', function(table) {
|
|
|
4
|
+ table.increments('user_id').primary()
|
|
|
5
|
+ table.string('user_name', 32).notNullable()
|
|
|
6
|
+ table.string('user_email', 90).notNullable()
|
|
|
7
|
+ table.timestamps(false, true) // Precision to the second
|
|
|
8
|
+ })
|
|
|
9
|
+ .createTable('accounts', function(table) {
|
|
|
10
|
+ table.increments('account_id').primary()
|
|
|
11
|
+ table.integer('user_id').notNullable()
|
|
|
12
|
+ table.timestamps(false, true) // Precision to the second
|
|
|
13
|
+ })
|
|
|
14
|
+ .createTable('logins', function(table) {
|
|
|
15
|
+ table.increments('login_id').primary()
|
|
|
16
|
+ table.integer('account_id').notNullable()
|
|
|
17
|
+ table.string('login_email', 90).notNullable()
|
|
|
18
|
+ table.string('login_password', 128).notNullable()
|
|
|
19
|
+ table.timestamps(false, true) // Precision to the second
|
|
|
20
|
+ })
|
|
|
21
|
+ .createTable('profiles', function(table) {
|
|
|
22
|
+ table.increments('profile_id').primary()
|
|
|
23
|
+ table.integer('account_id').notNullable()
|
|
|
24
|
+ table.string('profile_name', 128).notNullable()
|
|
|
25
|
+ table.json('profile_data').notNullable()
|
|
|
26
|
+ table.timestamps(false, true) // Precision to the second
|
|
|
27
|
+ })
|
|
|
28
|
+ .createTable('groupings', function(table) {
|
|
|
29
|
+ table.increments('grouping_id').primary()
|
|
|
30
|
+ table.string('grouping_name', 128).notNullable()
|
|
|
31
|
+ table.string('grouping_type', 128).notNullable() // Don't over normalize
|
|
|
32
|
+ table.timestamps(false, true) // Precision to the second
|
|
|
33
|
+ })
|
|
|
34
|
+ .createTable('memberships', function(table) {
|
|
|
35
|
+ table.increments('membership_id').primary()
|
|
|
36
|
+ table.integer('account_id').notNullable() // From
|
|
|
37
|
+ table.integer('group_id').notNullable() // To
|
|
|
38
|
+ table.string('membership_type', 128).notNullable() // Don't over normalize
|
|
|
39
|
+ table.string('membership_role', 128).notNullable() // Don't over normalize
|
|
|
40
|
+ })
|
|
|
41
|
+ .createTable('chats', function(table) {
|
|
|
42
|
+ table.increments('chat_id').primary()
|
|
|
43
|
+ table.integer('membership_id').notNullable()
|
|
|
44
|
+ table.timestamps(false, true) // Precision to the second
|
|
|
45
|
+ })
|
|
|
46
|
+ .createTable('messages', function(table) {
|
|
|
47
|
+ table.increments('message_id').primary()
|
|
|
48
|
+ table.integer('chat_id').notNullable()
|
|
|
49
|
+ table.integer('message_account_id').notNullable()
|
|
|
50
|
+ table.string('message', 255).notNullable()
|
|
|
51
|
+ })
|
|
|
52
|
+}
|
|
|
53
|
+
|
|
|
54
|
+exports.down = function(knex) {
|
|
|
55
|
+ return knex.schema
|
|
|
56
|
+ .dropTable('users')
|
|
|
57
|
+ .dropTable('accounts')
|
|
|
58
|
+ .dropTable('logins')
|
|
|
59
|
+ .dropTable('profiles')
|
|
|
60
|
+ .dropTable('memberships')
|
|
|
61
|
+ .dropTable('groupings')
|
|
|
62
|
+ .dropTable('chats')
|
|
|
63
|
+ .dropTable('messages')
|
|
|
64
|
+}
|