步骤如下:
1、切换intellij的运行环境为proteus shell,并运行
2、在 proteus shell中执行如下命令:dc list
注释:( This command will list all the un-completed data conversion in the system. You shall see a task named "proteus#3" which help you to create proteus admin role and group, run this task. )
注意: proteus#3 : proteus是id,3是你方法中的数字
3、 在 proteus shell中执行如下命令: dc run --id proteus --version 3 --user yhuang
4、执行命令:orm2dc
4、根据自己的实体类修改这个新产生的方法,并把它粘贴到ExampleAppDataConversionVersion1中
5、重启proteus shell
6、再次输入命令:dc list (则会多出自己新加的这个data conversion)
7、执行命令: dc run --id proteus --version 4 --user yhuang
则创建数据库表成功。
例子(example-app这个项目):
所有的命令均在proteus shell中执行
第一步:
从第一步中可以看出id为example-app,已经存在的version有1 2 3
第二步:执行命令:dc run --id example-app --version 4 --user yhuang
第三步:执行命令:orm2dc
产生一个新的data conversion的method
第四步:将最终的该方法放到ExampleAppDataConversionVersion1中,新产生的方法经过我的修改后如下:
/**
* Professor Entity
* @return Bean.
*/
@TaskQualifier(TaskQualifier.Type.data_conversion)
@Bean
public DataConversion professorEntityDataConversion()
{
List<SQLStatement> ddl = new ArrayList<>();
ddl.add(new SQLStatement("create table professor (professor_id int8 not null, createtime timestamp, lastmodtime timestamp, rank varchar(255), researcharea varchar(255), sabbatical boolean not null, slug varchar(255), startdate timestamp, name_id int8, site_id int8, primary key (professor_id))",null));
ddl.add(new SQLStatement("alter table professor add constraint FK_g6tqhhujo16yy4qjkjrmctis6 foreign key (name_id) references personname",null));
ddl.add(new SQLStatement("alter table professor add constraint FK_355w5ajb1ufoyd2ucbnd1uymd foreign key (site_id) references site",null));
ddl.add(new SQLStatement("create sequence professor_seq",null));
return SQLDataConversion.createSchemaUpdate("example-app","Professor Entity", 4, false, ddl);
}
5、重启proteus shell
6、再次输入命令:dc list (则会多出自己新加的这个data conversion)
7、执行命令: dc run --id example-app --version 4 --user yhuang
则创建数据库表成功。