Skip to content

Commit

Permalink
Merge pull request #1625 from ConductionNL/feature/OP-206/multi-tenan…
Browse files Browse the repository at this point in the history
…cy-config

Added multi tenant object databases
  • Loading branch information
WilcoLouwerse authored Mar 18, 2024
2 parents d68f3fc + 0c6f4fb commit 17c18c5
Show file tree
Hide file tree
Showing 5 changed files with 486 additions and 0 deletions.
39 changes: 39 additions & 0 deletions api/migrations/Version20240314120005.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240314120005 extends AbstractMigration
{
public function getDescription(): string
{
return 'Added a Database Entity for Multi-tenancy';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SEQUENCE database_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE database (id UUID NOT NULL, name VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, reference VARCHAR(255) NOT NULL, version VARCHAR(255) NOT NULL DEFAULT \'0.0.0\', uri VARCHAR(255) NOT NULL, date_created TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, date_modified TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE organization ADD database_id UUID DEFAULT NULL');
$this->addSql('ALTER TABLE organization ADD CONSTRAINT FK_C1EE637CF0AA09DB FOREIGN KEY (database_id) REFERENCES database (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_C1EE637CF0AA09DB ON organization (database_id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organization DROP CONSTRAINT FK_C1EE637CF0AA09DB');
$this->addSql('DROP INDEX IDX_C1EE637CF0AA09DB');
$this->addSql('ALTER TABLE organization DROP database_id');
$this->addSql('DROP SEQUENCE database_id_seq CASCADE');
$this->addSql('DROP TABLE database');
}
}
Loading

0 comments on commit 17c18c5

Please sign in to comment.