playframework-evolutions

Play Framework 2.3 how to reset database?

会有一股神秘感。 提交于 2020-01-14 09:07:07
问题 In the Play 2.3.x documentation on Evolutions it says In development mode however it is often simpler to simply trash your development database and reapply all evolutions from the beginning. However it doesn't give instructions on how to do this. Is there some kind of activator command I can use to do this? How can I reset and reapply evolutions? Thanks! Update: I would prefer not to have to mess with my DB manually, but it seems like that's the only way 回答1: If you don't care about the data

Regenerate evolution scripts in play 2

这一生的挚爱 提交于 2019-12-29 00:08:11
问题 I am still developing first version of my application on play 2. How could I regenerate evolution scripts? 回答1: Disclaimer : it will destroy your existing database and create new one! The auto-evolution will auto-regenerate when: you are running your app in the dev mode in application.conf you have this line not commented : ebean.default="models.*" there is only one file in your evolutions folder and it's 1.sql it has this comment at the beginning: # --- Created by Ebean DDL 回答2: Using play 2

Play Framework DML insert script

跟風遠走 提交于 2019-12-25 03:37:51
问题 I am using Play Framework 2.3 with Slick and an in-memory H2 databse. When I start the application, I would like to not only create the database from the evolution script, but as well insert some default data. This topic doesen't seem to be covered in the Play documentation. 回答1: It is possible to create a custom evolution script and place the DML in it. There is an activator template with this functionality – see the 2.sql file here. 来源: https://stackoverflow.com/questions/29571498/play

Rolling an evolution back

久未见 提交于 2019-12-21 07:07:42
问题 This question might seem stupid, but I cannot find any instruction on how to roll back an evolution in Play 2.0. Google only finds pages which say that the "Downs" section of an evolution file is used for that and that's all. Any pointers or instructions will be appreciated. 回答1: The Downs part is mainly used to revert an Evolution when the script has changed. That is, you have a project with 2.sql applied to the database and then, due to a merge, 2.sql is modified in the source. Play will

How one should handle incremental database schema evolution

99封情书 提交于 2019-12-11 23:48:30
问题 I have a Play framework powered application with database as a persistance layer (and I use Slick for that). I have enabled evolutions, generated 1.sql file and successfully rolled it out to production. Client requests new features that require database schema modifications - ie. adding new tables, adding new columns and changes to existing columns' nullability. Once all Slick's Table definitions and related code are updated, I generate schema once again and place it as 2.sql . Evolutions are

How to make Playframework Evolutions logging more verbose?

笑着哭i 提交于 2019-12-11 06:08:00
问题 I've been trying to see what's going on with them, as I'm facing a problem. When I click the "apply this script" button, the page asking me to apply the script appears again, and it stucks in that loop. It creates the "play_evolutions" table, but no script is run. The log in the console doesn't give me any relevant info. I've run manually the script and it's ok... So I wan't to know what the real problem is, therefore I need more logging. 回答1: Evolutions are not very verbose in general (when

Converting Play! framework evolution from MySQL to PostgreSQL

让人想犯罪 __ 提交于 2019-12-10 17:05:28
问题 I am using plaframework 2.2.1, I had made a project MySQL but now i want to shift my project to PostgreSQL but having some errors recreating the DB evolution. My old evolution(1.sql) for mysql which worked fine is: # --- Created by Ebean DDL # To stop Ebean DDL generation, remove this comment and start using Evolutions # --- !Ups create table product ( id bigint auto_increment not null, name varchar(255), price float, constraint pk_product primary key (id)) ; create table shop ( id bigint

How to apply play-evolutions when running tests in play-framework?

陌路散爱 提交于 2019-12-10 12:42:22
问题 I have problems with evolutions when running tests in play framework using playframework v2.6.6 for scala play-slick v3.0.2 play-slick-evolutions v3.0.2 The test looks like this: class TestFooController extends PlaySpec with GuiceOneServerPerSuite { "foo endpoint should store some data" in { val wsClient = app.injector.instanceOf[WSClient] val url = s"http://localhost:$port/foo" val requestData = Json.obj("foo" -> "bar") val response = await(wsClient.url(url).post(requestData)) response

How do I create a function in PostgreSQL using evolutions in the Play framework?

我们两清 提交于 2019-12-08 16:21:12
问题 With the Play Framework 2.1 I have the following SQL defined in my evolution: CREATE OR REPLACE FUNCTION idx(myArray anyarray, myElement anyelement) RETURNS int AS $$ SELECT i FROM ( SELECT generate_series(array_lower(myArray,1),array_upper(myArray,1)) ) g(i) WHERE myArray[i] = anyElement LIMIT 1; $$ LANGUAGE sql IMMUTABLE; When I execute the evolution, I get the following error: We got the following error: ERROR: unterminated dollar-quoted string at or near "$$ SELECT i FROM ( SELECT

Play framework and Slick automatic database creation

故事扮演 提交于 2019-12-05 01:53:27
问题 I'm using play 2.4 and Slick 3, Is it possible to generate automatically ddl scripts, it is evolutions? In official docs I found some scripts, but where should I place it in play framework? http://slick.typesafe.com/doc/3.1.0/schemas.html Do you know any libs to manage evolutions in code to not write plain SQL? 回答1: I made some workaround with PostgresDriver, I've created module, that prints DDL to file. After every code change I just need to replace 1.sql or later modify next evolution