14 use Illuminate\Database\Migrations\Migration;
15 use Illuminate\Database\Schema\Builder;
16 use Illuminate\Database\Schema\Blueprint;
17 use Illuminate\Database\Capsule\Manager as Capsule;
24 public function up() {
26 Capsule::schema()->create(
'journals',
function (Blueprint $table) {
27 $table->bigInteger(
'journal_id')->autoIncrement();
28 $table->string(
'path', 32);
29 $table->float(
'seq', 8, 2)->
default(0)->comment(
'Used to order lists of journals');
30 $table->string(
'primary_locale', 14);
31 $table->smallInteger(
'enabled')->
default(1)->comment(
'Controls whether or not the journal is considered "live" and will appear on the website. (Note that disabled journals may still be accessible, but only if the user knows the URL.)');
32 $table->unique([
'path'],
'journals_path');
36 Capsule::schema()->create(
'journal_settings',
function (Blueprint $table) {
37 $table->bigInteger(
'journal_id');
38 $table->string(
'locale', 14)->
default(
'');
39 $table->string(
'setting_name', 255);
40 $table->mediumText(
'setting_value')->nullable();
41 $table->string(
'setting_type', 6)->nullable();
42 $table->index([
'journal_id'],
'journal_settings_journal_id');
43 $table->unique([
'journal_id',
'locale',
'setting_name'],
'journal_settings_pkey');
47 Capsule::schema()->create(
'sections',
function (Blueprint $table) {
48 $table->bigInteger(
'section_id')->autoIncrement();
49 $table->bigInteger(
'journal_id');
50 $table->bigInteger(
'review_form_id')->nullable();
51 $table->float(
'seq', 8, 2)->
default(0);
52 $table->smallInteger(
'editor_restricted')->
default(0);
53 $table->smallInteger(
'meta_indexed')->
default(0);
54 $table->smallInteger(
'meta_reviewed')->
default(1);
55 $table->smallInteger(
'abstracts_not_required')->
default(0);
56 $table->smallInteger(
'hide_title')->
default(0);
57 $table->smallInteger(
'hide_author')->
default(0);
58 $table->smallInteger(
'is_inactive')->
default(0);
59 $table->bigInteger(
'abstract_word_count')->nullable();
60 $table->index([
'journal_id'],
'sections_journal_id');
64 Capsule::schema()->create(
'section_settings',
function (Blueprint $table) {
65 $table->bigInteger(
'section_id');
66 $table->string(
'locale', 14)->
default(
'');
67 $table->string(
'setting_name', 255);
68 $table->text(
'setting_value')->nullable();
69 $table->string(
'setting_type', 6)->comment(
'(bool|int|float|string|object)');
70 $table->index([
'section_id'],
'section_settings_section_id');
71 $table->unique([
'section_id',
'locale',
'setting_name'],
'section_settings_pkey');
75 Capsule::schema()->create(
'issues',
function (Blueprint $table) {
76 $table->bigInteger(
'issue_id')->autoIncrement();
77 $table->bigInteger(
'journal_id');
78 $table->smallInteger(
'volume')->nullable();
79 $table->string(
'number', 40)->nullable();
80 $table->smallInteger(
'year')->nullable();
81 $table->smallInteger(
'published')->
default(0);
82 $table->smallInteger(
'current')->
default(0);
83 $table->datetime(
'date_published')->nullable();
84 $table->datetime(
'date_notified')->nullable();
85 $table->datetime(
'last_modified')->nullable();
86 $table->smallInteger(
'access_status')->
default(1);
87 $table->datetime(
'open_access_date')->nullable();
88 $table->smallInteger(
'show_volume')->
default(0);
89 $table->smallInteger(
'show_number')->
default(0);
90 $table->smallInteger(
'show_year')->
default(0);
91 $table->smallInteger(
'show_title')->
default(0);
92 $table->string(
'style_file_name', 90)->nullable();
93 $table->string(
'original_style_file_name', 255)->nullable();
94 $table->string(
'url_path', 64)->nullable();
95 $table->index([
'journal_id'],
'issues_journal_id');
96 $table->index([
'url_path'],
'issues_url_path');
100 Capsule::schema()->create(
'issue_settings',
function (Blueprint $table) {
101 $table->bigInteger(
'issue_id');
102 $table->string(
'locale', 14)->
default(
'');
103 $table->string(
'setting_name', 255);
104 $table->text(
'setting_value')->nullable();
105 $table->string(
'setting_type', 6);
106 $table->index([
'issue_id'],
'issue_settings_issue_id');
107 $table->unique([
'issue_id',
'locale',
'setting_name'],
'issue_settings_pkey');
110 switch (Capsule::connection()->getDriverName()) {
111 case 'mysql': Capsule::connection()->unprepared(
'CREATE INDEX issue_settings_name_value ON issue_settings (setting_name(50), setting_value(150))');
break;
112 case 'pgsql': Capsule::connection()->unprepared(
"CREATE INDEX issue_settings_name_value ON issue_settings (setting_name, setting_value) WHERE setting_name IN ('medra::registeredDoi', 'datacite::registeredDoi')");
break;
116 Capsule::schema()->create(
'issue_galleys',
function (Blueprint $table) {
117 $table->bigInteger(
'galley_id')->autoIncrement();
118 $table->string(
'locale', 14)->nullable();
119 $table->bigInteger(
'issue_id');
120 $table->bigInteger(
'file_id');
121 $table->string(
'label', 32)->nullable();
122 $table->float(
'seq', 8, 2)->
default(0);
123 $table->string(
'url_path', 64)->nullable();
124 $table->index([
'issue_id'],
'issue_galleys_issue_id');
125 $table->index([
'url_path'],
'issue_galleys_url_path');
129 Capsule::schema()->create(
'issue_galley_settings',
function (Blueprint $table) {
130 $table->bigInteger(
'galley_id');
131 $table->string(
'locale', 14)->
default(
'');
132 $table->string(
'setting_name', 255);
133 $table->text(
'setting_value')->nullable();
134 $table->string(
'setting_type', 6)->comment(
'(bool|int|float|string|object)');
135 $table->index([
'galley_id'],
'issue_galley_settings_galley_id');
136 $table->unique([
'galley_id',
'locale',
'setting_name'],
'issue_galley_settings_pkey');
139 Capsule::schema()->create(
'issue_files',
function (Blueprint $table) {
140 $table->bigInteger(
'file_id')->autoIncrement();
141 $table->bigInteger(
'issue_id');
142 $table->string(
'file_name', 90);
143 $table->string(
'file_type', 255);
144 $table->bigInteger(
'file_size');
145 $table->bigInteger(
'content_type');
146 $table->string(
'original_file_name', 127)->nullable();
147 $table->datetime(
'date_uploaded');
148 $table->datetime(
'date_modified');
149 $table->index([
'issue_id'],
'issue_files_issue_id');
153 Capsule::schema()->create(
'custom_issue_orders',
function (Blueprint $table) {
154 $table->bigInteger(
'issue_id');
155 $table->bigInteger(
'journal_id');
156 $table->float(
'seq', 8, 2)->
default(0);
157 $table->unique([
'issue_id'],
'custom_issue_orders_pkey');
161 Capsule::schema()->create(
'custom_section_orders',
function (Blueprint $table) {
162 $table->bigInteger(
'issue_id');
163 $table->bigInteger(
'section_id');
164 $table->float(
'seq', 8, 2)->
default(0);
165 $table->unique([
'issue_id',
'section_id'],
'custom_section_orders_pkey');
169 Capsule::schema()->create(
'submission_tombstones',
function (Blueprint $table) {
170 $table->bigInteger(
'tombstone_id')->autoIncrement();
171 $table->bigInteger(
'submission_id');
172 $table->datetime(
'date_deleted');
173 $table->bigInteger(
'journal_id');
174 $table->bigInteger(
'section_id');
175 $table->string(
'set_spec', 255);
176 $table->string(
'set_name', 255);
177 $table->string(
'oai_identifier', 255);
178 $table->index([
'journal_id'],
'submission_tombstones_journal_id');
179 $table->index([
'submission_id'],
'submission_tombstones_submission_id');
183 Capsule::schema()->create(
'publications',
function (Blueprint $table) {
184 $table->bigInteger(
'publication_id')->autoIncrement();
185 $table->bigInteger(
'access_status')->
default(0)->nullable();
186 $table->date(
'date_published')->nullable();
187 $table->datetime(
'last_modified')->nullable();
188 $table->string(
'locale', 14)->nullable();
189 $table->bigInteger(
'primary_contact_id')->nullable();
190 $table->bigInteger(
'section_id')->nullable();
191 $table->float(
'seq', 8, 2)->
default(0);
192 $table->bigInteger(
'submission_id');
193 $table->smallInteger(
'status')->
default(1);
194 $table->string(
'url_path', 64)->nullable();
195 $table->bigInteger(
'version')->nullable();
196 $table->index([
'submission_id'],
'publications_submission_id');
197 $table->index([
'section_id'],
'publications_section_id');
198 $table->index([
'url_path'],
'publications_url_path');
202 Capsule::schema()->create(
'publication_galleys',
function (Blueprint $table) {
203 $table->bigInteger(
'galley_id')->autoIncrement();
204 $table->string(
'locale', 14)->nullable();
205 $table->bigInteger(
'publication_id');
206 $table->string(
'label', 255)->nullable();
207 $table->bigInteger(
'file_id')->nullable();
208 $table->float(
'seq', 8, 2)->
default(0);
209 $table->string(
'remote_url', 2047)->nullable();
210 $table->smallInteger(
'is_approved')->
default(0);
211 $table->string(
'url_path', 64)->nullable();
212 $table->index([
'publication_id'],
'publication_galleys_publication_id');
213 $table->index([
'url_path'],
'publication_galleys_url_path');
217 Capsule::schema()->create(
'publication_galley_settings',
function (Blueprint $table) {
218 $table->bigInteger(
'galley_id');
219 $table->string(
'locale', 14)->
default(
'');
220 $table->string(
'setting_name', 255);
221 $table->text(
'setting_value')->nullable();
222 $table->index([
'galley_id'],
'publication_galley_settings_galley_id');
223 $table->unique([
'galley_id',
'locale',
'setting_name'],
'publication_galley_settings_pkey');
226 switch (Capsule::connection()->getDriverName()) {
227 case 'mysql': Capsule::connection()->unprepared(
'CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name(50), setting_value(150))');
break;
228 case 'pgsql': Capsule::connection()->unprepared(
"CREATE INDEX publication_galley_settings_name_value ON publication_galley_settings (setting_name, setting_value)");
break;
232 Capsule::schema()->create(
'subscription_types',
function (Blueprint $table) {
233 $table->bigInteger(
'type_id')->autoIncrement();
234 $table->bigInteger(
'journal_id');
235 $table->float(
'cost', 8, 2);
236 $table->string(
'currency_code_alpha', 3);
237 $table->smallInteger(
'non_expiring')->
default(0);
238 $table->smallInteger(
'duration')->nullable();
239 $table->smallInteger(
'format');
240 $table->smallInteger(
'institutional')->
default(0);
241 $table->smallInteger(
'membership')->
default(0);
242 $table->smallInteger(
'disable_public_display');
243 $table->float(
'seq', 8, 2);
247 Capsule::schema()->create(
'subscription_type_settings',
function (Blueprint $table) {
248 $table->bigInteger(
'type_id');
249 $table->string(
'locale', 14)->
default(
'');
250 $table->string(
'setting_name', 255);
251 $table->text(
'setting_value')->nullable();
252 $table->string(
'setting_type', 6);
253 $table->index([
'type_id'],
'subscription_type_settings_type_id');
254 $table->unique([
'type_id',
'locale',
'setting_name'],
'subscription_type_settings_pkey');
258 Capsule::schema()->create(
'subscriptions',
function (Blueprint $table) {
259 $table->bigInteger(
'subscription_id')->autoIncrement();
260 $table->bigInteger(
'journal_id');
261 $table->bigInteger(
'user_id');
262 $table->bigInteger(
'type_id');
263 $table->date(
'date_start')->nullable();
264 $table->datetime(
'date_end')->nullable();
265 $table->smallInteger(
'status')->
default(1);
266 $table->string(
'membership', 40)->nullable();
267 $table->string(
'reference_number', 40)->nullable();
268 $table->text(
'notes')->nullable();
272 Capsule::schema()->create(
'institutional_subscriptions',
function (Blueprint $table) {
273 $table->bigInteger(
'institutional_subscription_id')->autoIncrement();
274 $table->bigInteger(
'subscription_id');
275 $table->string(
'institution_name', 255);
276 $table->string(
'mailing_address', 255)->nullable();
277 $table->string(
'domain', 255)->nullable();
278 $table->index([
'subscription_id'],
'institutional_subscriptions_subscription_id');
279 $table->index([
'domain'],
'institutional_subscriptions_domain');
283 Capsule::schema()->create(
'institutional_subscription_ip',
function (Blueprint $table) {
284 $table->bigInteger(
'institutional_subscription_ip_id')->autoIncrement();
285 $table->bigInteger(
'subscription_id');
286 $table->string(
'ip_string', 40);
287 $table->bigInteger(
'ip_start');
288 $table->bigInteger(
'ip_end')->nullable();
289 $table->index([
'subscription_id'],
'institutional_subscription_ip_subscription_id');
290 $table->index([
'ip_start'],
'institutional_subscription_ip_start');
291 $table->index([
'ip_end'],
'institutional_subscription_ip_end');
295 Capsule::schema()->create(
'queued_payments',
function (Blueprint $table) {
296 $table->bigInteger(
'queued_payment_id')->autoIncrement();
297 $table->datetime(
'date_created');
298 $table->datetime(
'date_modified');
299 $table->date(
'expiry_date')->nullable();
300 $table->text(
'payment_data')->nullable();
304 Capsule::schema()->create(
'completed_payments',
function (Blueprint $table) {
305 $table->bigInteger(
'completed_payment_id')->autoIncrement();
306 $table->datetime(
'timestamp');
307 $table->bigInteger(
'payment_type');
308 $table->bigInteger(
'context_id');
309 $table->bigInteger(
'user_id')->nullable();
310 $table->bigInteger(
'assoc_id')->nullable();
311 $table->float(
'amount', 8, 2);
312 $table->string(
'currency_code_alpha', 3)->nullable();
313 $table->string(
'payment_method_plugin_name', 80)->nullable();
323 Capsule::schema()->drop(
'completed_payments');
324 Capsule::schema()->drop(
'queued_payments');
325 Capsule::schema()->drop(
'institutional_subscription_ip');
326 Capsule::schema()->drop(
'institutional_subscriptions');
327 Capsule::schema()->drop(
'subscriptions');
328 Capsule::schema()->drop(
'subscription_type_settings');
329 Capsule::schema()->drop(
'subscription_types');
330 Capsule::schema()->drop(
'publication_galley_settings');
331 Capsule::schema()->drop(
'publication_galleys');
332 Capsule::schema()->drop(
'publications');
333 Capsule::schema()->drop(
'submission_tombstones');
334 Capsule::schema()->drop(
'custom_section_orders');
335 Capsule::schema()->drop(
'custom_issue_orders');
336 Capsule::schema()->drop(
'issue_files');
337 Capsule::schema()->drop(
'issue_galley_settings');
338 Capsule::schema()->drop(
'issue_galleys');
339 Capsule::schema()->drop(
'issue_settings');
340 Capsule::schema()->drop(
'issues');
341 Capsule::schema()->drop(
'section_settings');
342 Capsule::schema()->drop(
'sections');
343 Capsule::schema()->drop(
'journal_settings');
344 Capsule::schema()->drop(
'journals');