Skip to content

Commit 70429e1

Browse files
authored
Merge pull request #26 from epochtalk/post-drafts
feat: add table for storing post drafts
2 parents 0eaeff2 + 75180a1 commit 70429e1

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)