In my Spring Boot application, I'm using CommandLineRunner to create a new schema and them import some test data after that.
@Profile("create-schema")
@Component
public class CreateSchema {
// creating schema inside. This works because I can see from the database
}
@Profile("import-data")
@Component
public class DataImporter {
}
and this is the sequence in application.properties
spring.profiles.active=${SPRING_PROFILE}, create-schema, import-data
And using this in application.properties
spring.jpa.properties.hibernate.default_schema=simba
Schema creation starts after the application has started; and after schema is created, import-data starts.
when import-data is running, I get an error that
relation
schema_name.table_name
does not exist
However, once the schema is created and I run the application again - it works. So, when I have to deploy my app where every time I have to create a schema to run some integration tests - it would fail there.
am I running something in wrong order?