Skip to content

Instantly share code, notes, and snippets.

@nobeans
Last active March 14, 2018 07:20
Show Gist options
  • Save nobeans/2cff4c564282f506a690b91965252c6d to your computer and use it in GitHub Desktop.
Save nobeans/2cff4c564282f506a690b91965252c6d to your computer and use it in GitHub Desktop.
Grails3で独自のスキーマを使う方法 (with database-migration plugin)

DB側でスキーマを生成しておく。

> CREATE SCHEMA my_schema;
or
> CREATE SCHEMA my_schema AUTHORIZATION my_user;

application.ymlに以下の設定を追加する。

# in application.yml
# GORMも含めてHibernate経由でアクセスする時に自動的に指定したスキーマ名のリレーションとしてアクセスする。
hibernate:
    default_schema: my_schema

...

# 起動時にDBマイグレーションを実行する。
# その時に指定したスキーマ名配下のリレーションとしてテーブル等を作成する。
grails:
    plugin:
        databasemigration:
            updateOnStart: true
            updateOnStartDefaultSchema: my_schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment