Skip to content

Instantly share code, notes, and snippets.

@sajithdilshan
Last active September 3, 2017 13:16
Show Gist options
  • Save sajithdilshan/6e59c33f594e921b930ab5d5028cffac to your computer and use it in GitHub Desktop.
Save sajithdilshan/6e59c33f594e921b930ab5d5028cffac to your computer and use it in GitHub Desktop.
defmodule Test.Repo.Migrations.SampleMigration do
use Ecto.Migration
def change do
create table(:TEST_TENANTS, primary_key: false) do
add :ID, :serial, primary_key: true
add :NAME, :string
end
create table(:TEST_GROUPS, primary_key: false) do
add :ID, :serial, primary_key: true
add :TENANT_ID, references(:TEST_TENANTS, column: :ID)
add :NAME, :string
end
create table(:TEST_USERS, primary_key: false) do
add :ID, :serial, primary_key: true
add :TENANT_ID, references(:TEST_TENANTS, column: :ID)
add :NAME, :string
end
create table(:TEST_GROUPS_USERS, primary_key: false) do
add :GROUP_ID, references(:TEST_GROUPS, column: :ID)
add :USER_ID, references(:TEST_USERS, column: :ID)
end
create table(:TEST_PERMISSIONS, primary_key: false) do
add :ID, :serial, primary_key: true
add :GROUP_ID, references(:TEST_GROUPS, column: :ID)
add :NAME, :string
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment