subsonic.migrations and Oracle XE
Posted
by andrecarlucci
on Stack Overflow
See other posts from Stack Overflow
or by andrecarlucci
Published on 2009-04-17T15:13:21Z
Indexed on
2010/06/13
6:12 UTC
Read the original article
Hit count: 693
Hello,
Probably I'm doing something wrong but here it goes:
I'm trying to create a database using subsonic.migrations in an OracleXE version 10.2.0.1.0. I have ODP v 10.2.0.2.20 installed.
This is my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="test" connectionString="Data Source=XE; User Id=test; Password=test;"/>
</connectionStrings>
<SubSonicService defaultProvider="test">
<providers>
<clear/>
<add name="test" type="SubSonic.OracleDataProvider, SubSonic" connectionStringName="test" generatedNamespace="testdb"/>
</providers>
</SubSonicService>
</configuration>
And that's my first migration:
public class Migration001_Init : Migration {
public override void Up() {
//Create the records table
TableSchema.Table records = CreateTable("asdf");
records.AddColumn("RecordName");
}
public override void Down() {
DropTable("asdf");
}
}
When I run the sonic.exe, I get this exception:
Setting ConfigPath: 'App.config'
Building configuration from D:\Users\carlucci\Documents\Visual Studio 2008\Projects\Wum\Wum.Migration\App.config
Adding connection to test
ERROR: Trying to execute migrate
Error Message: System.Data.OracleClient.OracleException: ORA-02253: especifica‡Æo de restri‡Æo nÆo permitida aqui
at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)
at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at SubSonic.OracleDataProvider.ExecuteQuery(QueryCommand qry) in D:\@SubSonic\SubSonic\SubSonic\DataProviders\OracleDataProvider.cs:line 350
at SubSonic.DataService.ExecuteQuery(QueryCommand cmd) in D:\@SubSonic\SubSonic\SubSonic\DataProviders\DataService.cs:line 544
at SubSonic.Migrations.Migrator.CreateSchemaInfo(String providerName) in D:\@SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 249
at SubSonic.Migrations.Migrator.GetCurrentVersion(String providerName) in D:\@SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 232
at SubSonic.Migrations.Migrator.Migrate(String providerName, String migrationDirectory, Nullable`1 toVersion) in D:\@SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 50
at SubSonic.SubCommander.Program.Migrate() in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 264
at SubSonic.SubCommander.Program.Main(String[] args) in D:\@SubSonic\SubSonic\SubCommander\Program.cs:line 90
Execution Time: 379ms
What am I doing wrong?
Thanks a lot for any help :)
Andre Carlucci
UPDATE: As pointed by Anton, the problem is the subsonic OracleSqlGenerator. It is trying to create the schema table using this sql:
CREATE TABLE SubSonicSchemaInfo (
version int NOT NULL CONSTRAINT DF_SubSonicSchemaInfo_version DEFAULT (0)
)
Which doesn't work on oracle. The correct sql would be:
CREATE TABLE SubSonicSchemaInfo (
version int DEFAULT (0),
constraint DF_SubSonicSchemaInfo_version primary key (version)
)
The funny thing is that since this is the very first sql executed by subsonic migrations, NOBODY EVER TESTED it on oracle.
© Stack Overflow or respective owner