I have the following hibernate.cfg.xml file
The problem, when I run the migration, the schema is not getting created in the database. I would like to create the schema from scratch. It only generates the script.sql file.
This I the main app file
public class DatabaseMigration { public static void main(String[] args){ StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().configure("/META-INF/hibernate.cfg.xml").build(); Metadata meta = new MetadataSources(ssr).getMetadataBuilder().build(); SchemaExport schemaExport = new SchemaExport(); schemaExport.setHaltOnError(true); schemaExport.setFormat(true); schemaExport.setDelimiter(";"); schemaExport.setOutputFile("db-schema.sql"); schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), meta); } }
Thanks, guys, I have found the mistake.
schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), meta); was the problem
the target only specifies SCRIPT.
I have replaced it with DATABASE and it works.
1.4m articles
1.4m replys
5 comments
56.9k users