Within a SubSonic migration this code:
public override void Up()
{
TableSchema.Table test = CreateTableWithKey("test");
AddSubSonicStateColumns(test);
base.Up();
}
generates the following ddl for MySQL:
CREATE TABLE `test` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`CreatedOn` datetime ,
`ModifiedOn` datetime ,
`CreatedBy` nvarchar(64) NULL,
`ModifiedBy` nvarchar(64) NULL,
PRIMARY KEY (`id`)
);
But if I have an existing table and decide to add the Columns afterwards:
public override void Up()
{
TableSchema.Table oldtable1 = GetTable("oldtable1");
AddSubSonicStateColumns(oldtable1);
TableSchema.Table oldtable2 = new TableSchema.Table("oldtable2");
AddSubSonicStateColumns(oldtable2);
base.Up();
}
both ways don't seem to generate any sql. Well I know I can do:
AddColumn("oldtable3", "CreatedOn", System.Data.DbType.DateTime, 0, true);
AddColumn("oldtable3", "ModifiedOn", System.Data.DbType.DateTime, 0, true);
AddColumn("oldTable3", "CreatedBy", System.Data.DbType.String, 64, true);
AddColumn("oldTable3", "ModifiedBy", System.Data.DbType.String, 64, true);
but AddSubSonicStateColumns looks more elegant.