Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add table for storing post drafts #26

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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