1

我是玩框架的新手。

是否有像 rails 这样的模型生成和模型迁移工具

rails generage
rake db:migrate

有没有像铁轨一样的地方

app/models 模型专用目录?为模型推荐的目录 ID 是什么?

提前致谢

4

2 回答 2

1

模型生成

默认情况下,Play 使用多个演变脚本跟踪您的数据库演变。这些脚本是用纯文本编写的old SQL,应该位于conf/evolutions/{database name}应用程序的目录中。

如何迁移?

每个脚本包含两部分:

The Ups part the describe the required transformations.
The Downs part that describe how to revert them.

这是一个链接:http ://www.playframework.com/documentation/2.0/Evolutions

回答您的问题:推荐/约定播放模型定义哪个目录?

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

如您所见,用户定义的模型位于app/models. 此目录下的具体模型布局完全取决于您。

于 2013-08-11T20:04:31.663 回答
0

我建议你也看看 Migrate 插件,它是仿照 Rails 的db:migrate

http://www.playframework.com/modules/migrate-1.4/home

于 2013-08-12T09:44:00.003 回答