Search code examples
mysqlspring-bootebean

Why data inside database is deleting after running ebean.mysqldatabase.ddl.run=true?


I'm making project using SpringBoot and Ebean orm with MySql Database. I have created few tables in database. Now I wanted to add the column in existing table without deleting past records which is present in that table before running the application. But the problem is that whenever I run the application by adding ebean.mysqldatabase.ddl.run=true to the ebean.properites file to add the column in existing table the past records are deleting automatically.

How to add the column in existing table without deleting records?


Solution

  • ebean.ddl.generate=true -> execute CREATE ALL and DROP ALL DDL scripts which create all the tables

    When DDL is generated db-create-all.sql and db-drop-all.sql are generated and put into the maven target or gradle build directory. see DDL generate

    you can execute ebean.ddl.generate=true only to generate your Tables , After that, set the properite as false -> ebean.ddl.generate=false