This question is locked. New answers and comments are not allowed.
Hi.
I'm currently use version 2015.1.225.1 of OA and sqlite. I have schema update which includes default values for some columns. For simplicity, let's suppose that I'm adding only one colum of type double with default value of 5.0. I have following code:
using
(var updateContext =
new
OpenAccessContext(conStr, config, metadata))
{
var schemaHandler = updateContext.GetSchemaHandler();
string
script;
if
(schemaHandler.DatabaseExists())
{
SchemaUpdateProperties schemaUpdProps =
new
SchemaUpdateProperties
{
CheckConstraint =
true
,
CheckExtraColumns =
true
,
CheckExtraIndexes =
true
,
CheckIndex =
true
,
CheckLength =
true
,
CheckNulls =
true
,
CheckPK =
true
,
CheckScale =
true
,
CheckType =
true
};
SchemaUpdateInfo schemaUpdateInfo = schemaHandler.CreateUpdateInfo(schemaUpdProps);
script = schemaHandler.CreateUpdateDDLScript(schemaUpdProps);
}
else
{
schemaHandler.CreateDatabase();
script = schemaHandler.CreateDDLScript();
}
if
(!
string
.IsNullOrEmpty(script))
schemaHandler.ExecuteDDLScript(script);
}
So, after schemaHandler.CreateUpdateDDLScript(schemaUpdProps) is called I have following sql:
-- add column for field _property4
ALTER
TABLE
[ChildClass]
ADD
[Property4]
double
NOT
NULL
DEFAULT
0;
Obviously it is not desired default value. How can I solve it? Should I load my custom sql scripts for this situation or somehow parse and substitute default value?
Thanks in advance.