We have a countries table, which contains the country names which will never change.
How to populate country specific seed data using flyway on application start preferably with the same primary keys, so that it doesn't change across environments (say dev, qa, prod)
you can use flyway migrate
assuming this is the first scheme modification (otherwise start from consecutive V#)
V1__create_countries_table.sql:
create table COUNTRY (
ID int not null,
NAME varchar(100) not null
-- additional fields and constraints
);
V2__add_values_to_country_table.sql:
insert into COUNTRY (ID, NAME) values (1, 'Afghanistan');
insert into COUNTRY (ID, NAME) values (2, 'Albania');
...
since this is data is static and immutable you can protect it by overwriting create/update/delete on your java Country JPA Repository with throw new UnsupportedOperationException("country table is read only")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With