Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ecto node migration
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