Permalink
Browse files

New migrations - create database schema

  • Loading branch information...
1 parent aa7c1e7 commit c7c387797e889197fe263764bed7b6e2301fc9f6 = committed Oct 15, 2011
Showing with 36 additions and 0 deletions.
  1. +36 −0 app/DoctrineMigrations/Version20111015161300.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Application\Migrations;
+
+use Doctrine\DBAL\Migrations\AbstractMigration,
+ Doctrine\DBAL\Schema\Schema;
+
+/**
+ * Auto-generated Migration: Please modify to your need!
+ */
+class Version20111015161300 extends AbstractMigration
+{
+ public function up(Schema $schema)
+ {
+ // this up() migration is autogenerated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
+
+ $this->addSql("CREATE TABLE appointee (id VARCHAR(8) NOT NULL, revision SMALLINT NOT NULL, is_corporate TINYINT(1) NOT NULL, postcode VARCHAR(8) DEFAULT NULL, date_of_birth DATE DEFAULT NULL, title VARCHAR(50) DEFAULT NULL, forenames VARCHAR(50) DEFAULT NULL, surname VARCHAR(160) DEFAULT NULL, honours VARCHAR(50) DEFAULT NULL, care_of VARCHAR(100) DEFAULT NULL, po_box VARCHAR(10) DEFAULT NULL, address_1 VARCHAR(50) DEFAULT NULL, address_2 VARCHAR(50) DEFAULT NULL, town VARCHAR(50) DEFAULT NULL, county VARCHAR(50) DEFAULT NULL, country VARCHAR(50) DEFAULT NULL, occupation VARCHAR(40) DEFAULT NULL, nationality VARCHAR(40) DEFAULT NULL, residence VARCHAR(160) DEFAULT NULL, PRIMARY KEY(id, revision)) ENGINE = InnoDB");
+ $this->addSql("CREATE TABLE company (id VARCHAR(8) NOT NULL, status VARCHAR(16) NOT NULL, officers SMALLINT NOT NULL, name VARCHAR(161) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB");
+ $this->addSql("CREATE TABLE company_appointment (id INT AUTO_INCREMENT NOT NULL, appointee_id VARCHAR(8) NOT NULL, company_id VARCHAR(8) NOT NULL, type VARCHAR(35) NOT NULL, appointed_on DATE NOT NULL, appointment_date_source VARCHAR(32) NOT NULL, resigned_on DATE DEFAULT NULL, INDEX IDX_E7E940DC3275FC7 (appointee_id), INDEX IDX_E7E940DC979B1AD6 (company_id), PRIMARY KEY(id)) ENGINE = InnoDB");
+ $this->addSql("ALTER TABLE company_appointment ADD CONSTRAINT FK_E7E940DC3275FC7 FOREIGN KEY (appointee_id) REFERENCES appointee(id)");
+ $this->addSql("ALTER TABLE company_appointment ADD CONSTRAINT FK_E7E940DC979B1AD6 FOREIGN KEY (company_id) REFERENCES company(id)");
+ }
+
+ public function down(Schema $schema)
+ {
+ // this down() migration is autogenerated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
+
+ $this->addSql("ALTER TABLE company_appointment DROP FOREIGN KEY FK_E7E940DC3275FC7");
+ $this->addSql("ALTER TABLE company_appointment DROP FOREIGN KEY FK_E7E940DC979B1AD6");
+ $this->addSql("DROP TABLE appointee");
+ $this->addSql("DROP TABLE company");
+ $this->addSql("DROP TABLE company_appointment");
+ }
+}

0 comments on commit c7c3877

Please sign in to comment.