Beispiel #1
0
 /**
  * Returns the schema for this data object.
  *
  * @return \Rhubarb\Stem\Schema\ModelSchema
  */
 protected function createSchema()
 {
     $schema = new MySqlModelSchema("tblCompany");
     $schema->uniqueIdentifierColumnName = "CompanyID";
     $schema->addColumn(new AutoIncrement("CompanyID"), new String("CompanyName", 200), new Money("Balance"), new Date("InceptionDate"), new DateTime("LastUpdatedDate"), new Time("KnockOffTime"), new Boolean("BlueChip", false), new Integer("ProjectCount"), new Json("CompanyData"), new Boolean("Active", true));
     $schema->addIndex(new Index("CompanyID", Index::PRIMARY));
     $schema->labelColumnName = "CompanyName";
     return $schema;
 }
 public function testSchemaIsModified()
 {
     // Note this test relies on the previous test to leave tblExample behind.
     $schema = new MySqlModelSchema("tblExample");
     $schema->addColumn(new AutoIncrement("ID"));
     $schema->addColumn(new String("Name", 40, "StrangeDefault"));
     $schema->addColumn(new MySqlEnum("Type", "A", ["A", "B", "C"]));
     $schema->addColumn(new MySqlEnum("Type", "B", ["A", "B", "C", "D"]));
     $schema->addColumn(new String("Town", 60, null));
     $schema->addIndex(new Index("ID", Index::PRIMARY));
     $schema->checkSchema(Repository::getNewDefaultRepository(new Example()));
     $newSchema = MySqlComparisonSchema::fromTable("tblExample");
     $columns = $newSchema->columns;
     $this->assertCount(4, $columns);
     $this->assertEquals("`Town` varchar(60) DEFAULT NULL", $columns["Town"]);
     $this->assertEquals("`Type` enum('A','B','C','D') NOT NULL DEFAULT 'B'", $columns["Type"]);
 }