hasTable("SponsoredProject")) { $builder->create('SponsoredProject', function (Table $table) { $table->integer("ID", true, false); $table->primary("ID"); $table->timestamp('Created'); $table->timestamp('LastEdited'); $table->string('ClassName'); $table->string('Name')->setLength(255); $table->string('Description')->setNotnull(false)->setLength(1024); $table->string('Slug')->setLength(255); $table->boolean('IsActive'); $table->unique("Name"); $table->unique("Slug"); }); } if(!$schema->hasTable("ProjectSponsorshipType")) { $builder->create('ProjectSponsorshipType', function (Table $table) { $table->integer("ID", true, false); $table->primary("ID"); $table->timestamp('Created'); $table->timestamp('LastEdited'); $table->string('ClassName'); $table->string('Name')->setLength(255); $table->string('Description')->setNotnull(false)->setLength(1024); $table->string('Slug')->setLength(255); $table->integer('Order')->setDefault(1);; $table->boolean('IsActive'); // FK $table->integer("SponsoredProjectID", false, false)->setNotnull(false)->setDefault('NULL'); $table->index("SponsoredProjectID", "SponsoredProjectID"); $table->foreign("SponsoredProject", "SponsoredProjectID", "ID", ["onDelete" => "CASCADE"]); $table->unique(["Name", "SponsoredProjectID"]); $table->unique(["Slug", "SponsoredProjectID"]); }); } if(!$schema->hasTable("SupportingCompany")) { $builder->create('SupportingCompany', function (Table $table) { $table->integer("ID", true, false); $table->primary("ID"); $table->integer('Order')->setDefault(1); // FK $table->integer("CompanyID", false, false)->setNotnull(false)->setDefault('NULL'); $table->index("CompanyID", "CompanyID"); $table->foreign("Company", "CompanyID", "ID", ["onDelete" => "CASCADE"]); // FK $table->integer("ProjectSponsorshipTypeID", false, false)->setNotnull(false)->setDefault('NULL'); $table->index("ProjectSponsorshipTypeID", "ProjectSponsorshipTypeID"); $table->foreign("ProjectSponsorshipType", "ProjectSponsorshipTypeID", "ID", ["onDelete" => "CASCADE"]); }); } } /** * @param Schema $schema */ public function down(Schema $schema) { $builder = new Builder($schema); $builder->dropIfExists("SupportingCompany"); $builder->dropIfExists("ProjectSponsorshipType"); $builder->dropIfExists("SponsoredProject"); } }