Skip to content

Commit 75180a1

Browse files
committedJul 16, 2020
feat: add table for storing post drafts
1 parent cf5f96d commit 75180a1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
defmodule Epoch.Repo.Migrations.PostDrafts do
2+
use Ecto.Migration
3+
@schema_prefix "posts"
4+
5+
def up do
6+
execute "CREATE SCHEMA #{@schema_prefix}"
7+
8+
create table(:user_drafts, [prefix: @schema_prefix, primary_key: false]) do
9+
add :user_id, references(:users, type: :uuid, on_delete: :delete_all, prefix: "public"), null: false
10+
add :draft, :text
11+
add :updated_at, :timestamp
12+
end
13+
create unique_index(:user_drafts, [:user_id], prefix: @schema_prefix)
14+
end
15+
16+
def down do
17+
drop table(:user_drafts, [prefix: @schema_prefix])
18+
execute "DROP SCHEMA #{@schema_prefix}"
19+
end
20+
end

0 commit comments

Comments
 (0)
Please sign in to comment.