Skip to content

Commit

Permalink
Merge pull request #26 from epochtalk/post-drafts
Browse files Browse the repository at this point in the history
feat: add table for storing post drafts
  • Loading branch information
akinsey authored Jul 21, 2020
2 parents 0eaeff2 + 75180a1 commit 70429e1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions priv/repo/migrations/20200716204502_post_drafts.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule Epoch.Repo.Migrations.PostDrafts do
use Ecto.Migration
@schema_prefix "posts"

def up do
execute "CREATE SCHEMA #{@schema_prefix}"

create table(:user_drafts, [prefix: @schema_prefix, primary_key: false]) do
add :user_id, references(:users, type: :uuid, on_delete: :delete_all, prefix: "public"), null: false
add :draft, :text
add :updated_at, :timestamp
end
create unique_index(:user_drafts, [:user_id], prefix: @schema_prefix)
end

def down do
drop table(:user_drafts, [prefix: @schema_prefix])
execute "DROP SCHEMA #{@schema_prefix}"
end
end

0 comments on commit 70429e1

Please sign in to comment.