forked from liberuum/ql-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
20220821112057_release_202208.js
161 lines (143 loc) · 6.48 KB
/
20220821112057_release_202208.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//Up migration creates Core Unit and all root tables
export function up(knex) {
return knex.schema
.createTable('CoreUnit', function (table) {
console.log("Creating Core Unit table...");
table.increments('id').primary();
table.string('code').notNullable();
table.string('shortCode').notNullable();
table.string('name').notNullable();
table.string('image');
table.text('sentenceDescription');
table.text('paragraphDescription');
table.string('paragraphImage');
})
.createTable('CuMip', function (table) {
console.log("Creating CUMip table...");
table.increments('id').primary();
table.integer('cuId').notNullable();
table.foreign('cuId').references('CoreUnit.id').onDelete('CASCADE')
table.string('mipCode').notNullable();
table.string('mipTitle').notNullable();
table.date('rfc');
table.date('formalSubmission');
table.date('accepted');
table.date('rejected');
table.date('obsolete');
table.enu('mipStatus', ['RFC', 'Formal Submission', 'Accepted', 'Rejected', 'Obsolete', 'Withdrawn'], {
useNative: true,
enumName: 'MipStatus'
}).notNullable();
table.string('mipUrl');
table.string('forumUrl');
})
.createTable('BudgetStatement', function (table) {
console.log("Creating BudgetStatement table...");
table.increments('id').primary();
table.integer('cuId').notNullable();
table.foreign('cuId').references('CoreUnit.id').onDelete('CASCADE');
table.date('month').notNullable();
table.text('comments');
table.string('publicationUrl');
table.string('cuCode').notNullable();
table.enu('budgetStatus', ['Draft', 'SubmittedToAuditor', 'AwaitingCorrections', 'Final'], {
useNative: true,
enumName: 'BudgetStatus'
});
table.decimal('mkrProgramLength', 4, 2);
})
.createTable('SocialMediaChannels', function (table) {
console.log("Creating SocialMediaChannel table...");
table.increments('id').primary();
table.integer('cuId').notNullable();
table.foreign('cuId').references('CoreUnit.id').onDelete('CASCADE')
table.string('forumTag');
table.string('twitter');
table.string('youtube');
table.string('discord');
table.string('linkedin');
table.string('website');
table.string('github');
})
.createTable('Contributor', function (table) {
console.log("Creating Contributor table...");
table.increments('id').primary();
table.string('name').notNullable();
table.string('forumHandle').notNullable();
table.string('discordHandle').notNullable();
table.string('twitterHandle');
table.string('email');
table.string('githubUrl');
table.string('facilitatorImage');
})
.createTable('ContributorCommitment', function (table) {
console.log("Creating ContributorCommitment table...");
table.increments('id').primary();
table.integer('cuId').notNullable();
table.foreign('cuId').references('CoreUnit.id').onDelete('CASCADE')
table.integer('contributorId').notNullable();
table.foreign('contributorId').references('Contributor.id').onDelete('CASCADE')
table.date('startDate').notNullable();
table.enu('commitment', ['FullTime', 'PartTime', 'Variable', 'Inactive'], {
useNative: true,
enumName: 'Commitment'
}).notNullable();
table.string('title').notNullable();
})
.createTable('Roadmap', function (table) {
console.log("Creating Roadmap table...");
table.increments('id').primary();
table.integer('ownerCuId');
table.foreign('ownerCuId').references('CoreUnit.id').onDelete('CASCADE')
table.string('roadmapCode');
table.string('roadmapName').notNullable();
table.enu('roadmapStatus', ['ToDo', 'InProgress', 'Done'], {
useNative: true,
enumName: 'RoadmapStatus'
}).notNullable();
table.text('roadmapSummary');
table.boolean('strategicInitiative');
table.text('comments');
})
.createTable('CuUpdate', function (table) {
console.log("Creating CuUpdate table...");
table.increments('id').primary();
table.integer('cuId').notNullable();
table.foreign('cuId').references('CoreUnit.id').onDelete('CASCADE')
table.string('updateTitle').notNullable();
table.date('updateDate').notNullable();
table.string('updateUrl').notNullable();
})
.createTable('CuCategory', function (table) {
console.log("Creating cuCategory table...");
table.increments('id').primary();
table.string('category').notNullable();
})
.createTable('CoreUnit_CuCategory', function (table) {
console.log("Creating CoreUnit_CoreUnitCategory table...");
table.increments('id').primary();
table.integer('cuId').notNullable();
table.foreign('cuId').references('CoreUnit.id').onDelete('CASCADE');
table.integer('cuCategoryId').notNullable();
table.foreign('cuCategoryId').references('CuCategory.id').onDelete('CASCADE');
})
}
//Down migration deletes Core Unit and all root tables
export function down(knex) {
console.log("Dropping tables CoreUnit, CuMip, BudgetStatement, SocialMediaChannels, Contributor, ContributorCommitment, Roadmap, CuUpdate...");
return knex.schema
.dropTable("CoreUnit_CuCategory")
.dropTable("CuCategory")
.dropTable("CuUpdate")
.dropTable("Roadmap")
.dropTable("ContributorCommitment")
.dropTable("Contributor")
.dropTable("SocialMediaChannels")
.dropTable("BudgetStatement")
.dropTable("CuMip")
.dropTable("CoreUnit")
.raw('DROP TYPE "BudgetStatus"')
.raw('DROP TYPE "Commitment"')
.raw('DROP TYPE "MipStatus"')
.raw('DROP TYPE "RoadmapStatus"')
}