/// <summary> /// Creates a new table with a default integer primary key with the supplied name /// </summary> /// <param name="tableName">Name of table to create</param> /// <param name="keyName">Name of primary key</param> /// <returns>An empty table schema object.</returns> public TableSchema.Table CreateTableWithKey(string tableName, string keyName) { TableSchema.Table table = new TableSchema.Table(tableName); table.AddPrimaryKeyColumn(keyName); AddMigrationStep(MigrationStepType.CreateTable, table); return(table); }
public override void Up() { TableSchema.Table table = CreateTable("Distribution"); table.AddPrimaryKeyColumn("Id"); table.AddColumn("Name", DbType.String, 20); table.AddColumn("Capacity", DbType.Int32); table = CreateTable("ShipStatus"); table.AddColumn("Status", DbType.String, 50); table.AddColumn("Code", DbType.String, 4); AddSubSonicStateColumns(table); }
public void Create_Table() { TableSchema.Table testSchema = new TableSchema.Table("Southwind", "ShippingCarriers"); testSchema.AddPrimaryKeyColumn("Id"); testSchema.AddColumn("Name", DbType.String, 50, false); testSchema.AddColumn("Description", DbType.String, 100, false); ISqlGenerator generator = new MySqlGenerator(null); string sql = generator.BuildCreateTableStatement(testSchema); Assert.AreEqual( "CREATE TABLE `ShippingCarriers` (\r\n `Id` INTEGER NOT NULL AUTO_INCREMENT,\r\n `Name` nvarchar(50) NOT NULL,\r\n `Description` nvarchar(100) NOT NULL,\r\n PRIMARY KEY (`Id`) \r\n)", sql); }
public void MigrationOnDispose() { //testing Rob's super-cool migration on dispose pattern using (Migration m = new Migration("Northwind")) { TableSchema.Table t = m.CreateTable("DisposeTable"); t.AddPrimaryKeyColumn(); t.AddColumn("Name", DbType.String); m.AddSubSonicStateColumns(t); } DataService.ClearSchemaCache("Northwind"); TableSchema.Table table = DataService.GetSchema("DisposeTable", "Northwind"); Assert.IsNotNull(table); }