Reputation: 2681
I am new to play framework.
Is there a model generate and model migration tool like rails
rails generage
rake db:migrate
and is there a place like rails
app/models dedicated directory for models? What directory id recommended for models?
Thanks in advance
Upvotes: 1
Views: 395
Reputation: 5811
I suggest you to look at the Migrate plugin too, it's modelled after the Rails' db:migrate
:
http://www.playframework.com/modules/migrate-1.4/home
Upvotes: 0
Reputation: 33399
Model generation
By default, Play tracks your database evolutions using several evolutions script. These scripts are written in plain old SQL
and should be located in the conf/evolutions/{database name}
directory of your application.
How to migrate?
Each script contains two parts:
The Ups part the describe the required transformations.
The Downs part that describe how to revert them.
Here's a link: http://www.playframework.com/documentation/2.0/Evolutions
To answer your question: Which directory is recommended/convention for play models definition?
Here's the recommended play project layout:
app → Application sources
└ assets → Compiled asset sources
└ stylesheets → Typically LESS CSS sources
└ javascripts → Typically CoffeeScript sources
└ controllers → Application controllers
└ models → Application business layer
└ views → Templates
conf → Configurations files and other non-compiled resources (on classpath)
└ application.conf → Main configuration file
└ routes → Routes definition
public → Public assets
└ stylesheets → CSS files
└ javascripts → Javascript files
└ images → Image files
project → sbt configuration files
└ build.properties → Marker for sbt project
└ Build.scala → Application build script
└ plugins.sbt → sbt plugins
lib → Unmanaged libraries dependencies
logs → Standard logs folder
└ application.log → Default log file
target → Generated stuff
└ scala-2.10.0
└ cache
└ classes → Compiled class files
└ classes_managed → Managed class files (templates, ...)
└ resource_managed → Managed resources (less, ...)
└ src_managed → Generated sources (templates, ...)
test → source folder for unit or functional tests
As you can see, user-defined model goes under app/models
. It is really up to you regarding the specific model layout under this directory.
Upvotes: 1