Skip to content

Commit

Permalink
Only enable auto-create properties when generating scripts, and not when
Browse files Browse the repository at this point in the history
creating the database. Fixes #363
  • Loading branch information
andyjefferson committed Jan 20, 2021
1 parent 5fed562 commit bb333d2
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/main/java/org/datanucleus/PersistenceNucleusContextImpl.java
Expand Up @@ -412,26 +412,30 @@ public synchronized void initialise()
{
generateSchema = true;

// Add any properties that are needed by schema generation (before we create StoreManager)
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL))
if (generateScripts)
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_TABLES))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_TABLES, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_COLUMNS))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_COLUMNS, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_CONSTRAINTS))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_CONSTRAINTS, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_DATASTORE_READONLY))
{
config.setProperty(PropertyNames.PROPERTY_DATASTORE_READONLY, "false");
// Add any properties that are needed by schema generation (before we create StoreManager)
// since script creation requires it
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_ALL, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_TABLES))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_TABLES, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_COLUMNS))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_COLUMNS, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_CONSTRAINTS))
{
config.setProperty(PropertyNames.PROPERTY_SCHEMA_AUTOCREATE_CONSTRAINTS, "true");
}
if (!config.getBooleanProperty(PropertyNames.PROPERTY_DATASTORE_READONLY))
{
config.setProperty(PropertyNames.PROPERTY_DATASTORE_READONLY, "false");
}
}
}

Expand Down

0 comments on commit bb333d2

Please sign in to comment.