At this moment, the generated statement assumes the table does not exist and I cannot change this behavior. I would like to have a (general?) option to change the way how tables are created, for example in the project definition, like:
Project MyProject {
database_type: 'MySQL'
check_for_existence: true
}
table test {
id integer
}
which results in
create table if not exists test (
id integer
);
Or:
Project MyProject {
database_type: 'MySQL'
replace: true
}
table test {
id integer
}
which results in:
create or replace table (
id integer
);
@Wilfred_van_Dijk Thanks for the suggestion. Would a per-table option work for your case, instead of one setting for the whole project? It would let you mix behaviors in one script, for example CREATE OR REPLACE TABLE for staging tables and CREATE TABLE IF NOT EXISTS for tables that hold data. Or do you usually want the same behavior for every table?
We’re asking because a per-table option could be combined with your other suggestion. Each table would then have one place to set how it’s created and which options it gets on export, such as WITH SYSTEM VERSIONING. This is your other topic: Add table properties
A per table option is definitely a more flexible solution, but keep in mind some options are before the table definition and some options are after the table definition. I’ll leave it up to you/your team howto implement this …