Last active
August 29, 2015 14:07
-
-
Save taybin/ffc8c18f9c8459f5f47a to your computer and use it in GitHub Desktop.
ecto node migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Repo.Migrations.CreateNodes do | |
use Ecto.Migration | |
def up do | |
[ | |
"CREATE TABLE IF NOT EXISTS nodes(id SERIAL PRIMARY KEY, name TEXT NOT NULL, script TEXT)", | |
"CREATE TABLE IF NOT EXISTS node_to_node(parent_id INTEGER NOT NULL REFERENCES nodes(id) ON DELETE CASCADE, child_id INTEGER NOT NULL REFERENCES nodes(id) ON DELETE CASCADE)" | |
] | |
end | |
def down do | |
[ | |
"DROP TABLE node_to_node", | |
"DROP TABLE nodes" | |
] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment