Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot database initialization only one time

I have a spring boot backend application and I'm looking for a way to insert initialization data in a MySQL database but only each time the tables are created. I did that with data.sql but the data gets inserted every time the server starts. I hope my question is clear. Thank you for your time :)

like image 447
zgkais Avatar asked Sep 16 '25 06:09

zgkais


1 Answers

Database initialising provided by Spring Boot is meant to be used only with embedded databases. So it more or less assumes that you have to initialise the database on every start of the application.

For the proper initialising and evolution of persistent databases use Flyway or Liquibase

like image 177
Nikem Avatar answered Sep 19 '25 03:09

Nikem