public function testSchemaSetsIndexAndIdentifierWhenAutoIncrementAdded() { $schema = new MySqlModelSchema("tblTest"); $schema->addColumn(new AutoIncrement("TestID")); $this->assertEquals("TestID", $schema->uniqueIdentifierColumnName); $this->assertEquals(Index::PRIMARY, $schema->indexes["Primary"]->indexType); }
public function testColumnSetsIndex() { $schema = new MySqlModelSchema("tblTest"); $schema->addColumn(new ForeignKey("CompanyID")); $this->assertCount(1, $schema->indexes); $this->assertArrayHasKey("CompanyID", $schema->indexes); }
/** * 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; }