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(
'submission_files',
function (Blueprint $table) {
27 $table->bigInteger(
'file_id')->autoIncrement();
28 $table->bigInteger(
'revision');
29 $table->bigInteger(
'source_file_id')->nullable();
30 $table->bigInteger(
'source_revision')->nullable();
31 $table->bigInteger(
'submission_id');
32 $table->string(
'file_type', 255);
33 $table->bigInteger(
'genre_id')->nullable();
34 $table->bigInteger(
'file_size');
35 $table->string(
'original_file_name', 127)->nullable();
36 $table->bigInteger(
'file_stage');
37 $table->string(
'direct_sales_price', 255)->nullable();
38 $table->string(
'sales_type', 255)->nullable();
39 $table->smallInteger(
'viewable')->nullable();
40 $table->datetime(
'date_uploaded');
41 $table->datetime(
'date_modified');
42 $table->bigInteger(
'uploader_user_id')->nullable();
43 $table->bigInteger(
'assoc_type')->nullable();
44 $table->bigInteger(
'assoc_id')->nullable();
45 $table->index([
'submission_id'],
'submission_files_submission_id');
47 $table->index([
'file_stage',
'assoc_type',
'assoc_id'],
'submission_files_stage_assoc');
51 switch (Capsule::connection()->getDriverName()) {
52 case 'mysql': Capsule::connection()->unprepared(
"ALTER TABLE submission_files DROP PRIMARY KEY, ADD PRIMARY KEY (file_id, revision)");
break;
53 case 'pgsql': Capsule::connection()->unprepared(
"ALTER TABLE submission_files DROP CONSTRAINT submission_files_pkey; ALTER TABLE submission_files ADD PRIMARY KEY (file_id, revision);");
break;
56 Capsule::schema()->create(
'submission_file_settings',
function (Blueprint $table) {
57 $table->bigInteger(
'file_id');
58 $table->string(
'locale', 14)->
default(
'');
59 $table->string(
'setting_name', 255);
60 $table->text(
'setting_value')->nullable();
61 $table->string(
'setting_type', 6)->comment(
'(bool|int|float|string|object|date)');
62 $table->index([
'file_id'],
'submission_file_settings_id');
63 $table->unique([
'file_id',
'locale',
'setting_name'],
'submission_file_settings_pkey');
67 Capsule::schema()->create(
'submission_artwork_files',
function (Blueprint $table) {
68 $table->bigInteger(
'file_id');
69 $table->bigInteger(
'revision');
70 $table->text(
'caption')->nullable();
71 $table->string(
'credit', 255)->nullable();
72 $table->string(
'copyright_owner', 255)->nullable();
73 $table->text(
'copyright_owner_contact')->nullable();
74 $table->text(
'permission_terms')->nullable();
75 $table->bigInteger(
'permission_file_id')->nullable();
76 $table->bigInteger(
'chapter_id')->nullable();
77 $table->bigInteger(
'contact_author')->nullable();
81 Capsule::schema()->create(
'submission_supplementary_files',
function (Blueprint $table) {
82 $table->bigInteger(
'file_id');
83 $table->bigInteger(
'revision');
92 Capsule::schema()->drop(
'submission_supplementary_files');
93 Capsule::schema()->drop(
'submission_artwork_files');
94 Capsule::schema()->drop(
'submission_file_settings');
95 Capsule::schema()->drop(
'submission_files');