Migrations question

Topics: Troubleshooting
Developer
Mar 5, 2011 at 9:51 AM

Hey Guys any chance you could look over this for me please? Im concerned that the ExecuteSql step isent going to work because of namespaces and other stuff beign attached to tables in the DB.... Ideas? Cheers, Nick

 

        public int UpgradeFrom1() {
            SchemaBuilder.CreateTable("ProviderSettingsPartRecord",
                table => table
                    .ContentPartRecord()
                    .Column<string>("Provider")
                    .Column<string>("ClientIdentifier")
                    .Column<string>("ClientSecret")
                );

            SchemaBuilder.ExecuteSql("Insert into ProviderSettingsPartRecord (\"Provider\", \"ClientIdentifier\", \"ClientSecret\"))" +
                                     "Select \"Facebook\", FacebookClientIdentifier, FacebookClientSecret From OpenAuthenticationSettingsPartRecord");

            SchemaBuilder.ExecuteSql("Insert into ProviderSettingsPartRecord (\"Provider\", \"ClientIdentifier\", \"ClientSecret\"))" +
                                     "Select \"Twitter\", FacebookClientIdentifier, FacebookClientSecret From OpenAuthenticationSettingsPartRecord");

            SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", table => table.DropColumn("FacebookClientIdentifier"));
            SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", table => table.DropColumn("FacebookClientSecret"));
            SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", table => table.DropColumn("TwitterClientIdentifier"));
            SchemaBuilder.AlterTable("OpenAuthenticationSettingsPartRecord", table => table.DropColumn("TwitterClientSecret"));

return 2;

}