Play! framework - database issue with Evolutions

前端 未结 4 1022
深忆病人
深忆病人 2021-02-01 09:53

I\'m using Play! framework 2.0 and I\'m stuck on an annoying issue involving the database.

Suppose I have a User (extends Model) class which ha

4条回答
  •  萌比男神i
    2021-02-01 10:17

    First you need to disable automatic generation of Evolution files by deleting the first 2 commented lines of the conf/evolutions/default/1.sql:

    # --- Created by Ebean DDL
    # To stop Ebean DDL generation, remove this comment and start using Evolutions
    
    # --- !Ups
    ...
    

    Then, you need to create a second file, called conf/evolutions/default/2.sql containing your update on the database schema with an Ups and a Downs section:

    # --- !Ups
    ALTER TABLE USER ADD COLUMN last_ip varchar(30) DEFAULT NULL;
    
    # --- !Downs
    
    ALTER TABLE USER DELETE COLUMN last_ip;
    

提交回复
热议问题