openstackid-resources/database/migrations/model/Version20201119155826.php
smarcet 35fc57473c Sponsored Projects - Endpoints
POST /api/v1/sponsored-projects

payload

name
description
is_active

scope

REALM_URL/sponsored-projects/write

GET /api/v1/sponsored-projects

scope

REALM_URL/sponsored-projects/read

PUT /api/v1/sponsored-projects/{id}

payload

name
description
is_active

scope

REALM_URL/sponsored-projects/write

GET /api/v1/sponsored-projects/{id}
scope

REALM_URL/sponsored-projects/read

PUBLIC

GET /api/public/v1/sponsored-projects/{slug}

DELETE /api/v1/sponsored-projects/{id}

scope

REALM_URL/sponsored-projects/write

POST /api/v1/sponsored-projects/{id}/sponsorship-types

payload
name
description
is_active
order

scope

REALM_URL/sponsored-projects/write

GET /api/v1/sponsored-projects/{id}/sponsorship-types

scope

REALM_URL/sponsored-projects/read

GET /api/v1/sponsored-projects/{id}/sponsorship-types/{id}

scope

REALM_URL/sponsored-projects/read

DELETE /api/v1/sponsored-projects/{id}/sponsorship-types/{id}

scope

REALM_URL/sponsored-projects/write

PUT /api/v1/sponsored-projects/{id}/sponsorship-types/{id}

payload
name
description
is_active
order

scope

REALM_URL/sponsored-projects/write

PUT /api/v1/sponsored-projects/{id}/sponsorship-types/{id}/supporting-companies/{id}

payload
order (optional)

scope

REALM_URL/sponsored-projects/write

DELETE /api/v1/sponsored-projects/{id}/sponsorship-types/{id}/supporting-companies/{id}

scope

REALM_URL/sponsored-projects/write

GET /api/v1/sponsored-projects/{id}/sponsorship-types/{id}/supporting-companies

scope

REALM_URL/sponsored-projects/read

Change-Id: I9c0b1bb457a1c583afd284f56f2aced5deceaa02
Signed-off-by: smarcet <smarcet@gmail.com>
2020-11-30 15:09:40 -03:00

109 lines
4.1 KiB
PHP

<?php namespace Database\Migrations\Model;
/**
* Copyright 2019 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema as Schema;
use LaravelDoctrine\Migrations\Schema\Builder;
use LaravelDoctrine\Migrations\Schema\Table;
/**
* Class Version20201119155826
* @package Database\Migrations\Model
*/
class Version20201119155826 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$builder = new Builder($schema);
if(!$schema->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");
}
}