chore: migrate to prod

Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
Amogh Lele 2021-10-08 01:56:42 +05:30
parent 9b2da2dbf1
commit 3f424a41c1
No known key found for this signature in database
GPG Key ID: F0EA64BC1B44A7F3
4 changed files with 228 additions and 8 deletions

View File

@ -10,7 +10,7 @@ use Mix.Config
# which you should run after static files are built and
# before starting your production server.
config :ketbin, KetbinWeb.Endpoint,
url: [host: "dev.katb.in", port: 80],
url: [host: "katb.in", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production

View File

@ -4,16 +4,16 @@ defmodule Ketbin.Repo.Migrations.CreateUsersAuthTables do
def change do
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
create table(:users) do
create_if_not_exists table(:users) do
add :email, :citext, null: false
add :hashed_password, :string, null: false
add :confirmed_at, :naive_datetime
timestamps()
end
create unique_index(:users, [:email])
create_if_not_exists unique_index(:users, [:email])
create table(:users_tokens) do
create_if_not_exists table(:users_tokens) do
add :user_id, references(:users, on_delete: :delete_all), null: false
add :token, :binary, null: false
add :context, :string, null: false
@ -21,7 +21,7 @@ defmodule Ketbin.Repo.Migrations.CreateUsersAuthTables do
timestamps(updated_at: false)
end
create index(:users_tokens, [:user_id])
create unique_index(:users_tokens, [:context, :token])
create_if_not_exists index(:users_tokens, [:user_id])
create_if_not_exists unique_index(:users_tokens, [:context, :token])
end
end

View File

@ -2,13 +2,13 @@ defmodule Ketbin.Repo.Migrations.CreatePastes do
use Ecto.Migration
def change do
create table(:pastes, primary_key: false) do
create_if_not_exists table(:pastes, primary_key: false) do
add :id, :string, primary_key: true
add :is_url, :boolean, default: false, null: false
add :content, :text, null: false
add :belongs_to, references(:users, on_delete: :delete_all)
end
create index(:pastes, [:belongs_to])
create_if_not_exists index(:pastes, [:belongs_to])
end
end

220
priv/repo/structure.sql Normal file
View File

@ -0,0 +1,220 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 13.4 (Debian 13.4-1.pgdg100+1)
-- Dumped by pg_dump version 13.4
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: citext; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;
--
-- Name: EXTENSION citext; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION citext IS 'data type for case-insensitive character strings';
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: pastes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.pastes (
id character varying(255) NOT NULL,
is_url boolean DEFAULT false NOT NULL,
content text NOT NULL,
belongs_to bigint
);
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.schema_migrations (
version bigint NOT NULL,
inserted_at timestamp(0) without time zone
);
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
id bigint NOT NULL,
email public.citext NOT NULL,
hashed_password character varying(255) NOT NULL,
confirmed_at timestamp(0) without time zone,
inserted_at timestamp(0) without time zone NOT NULL,
updated_at timestamp(0) without time zone NOT NULL
);
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- Name: users_tokens; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users_tokens (
id bigint NOT NULL,
user_id bigint NOT NULL,
token bytea NOT NULL,
context character varying(255) NOT NULL,
sent_to character varying(255),
inserted_at timestamp(0) without time zone NOT NULL
);
--
-- Name: users_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.users_tokens_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: users_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_tokens_id_seq OWNED BY public.users_tokens.id;
--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- Name: users_tokens id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users_tokens ALTER COLUMN id SET DEFAULT nextval('public.users_tokens_id_seq'::regclass);
--
-- Name: pastes pastes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.pastes
ADD CONSTRAINT pastes_pkey PRIMARY KEY (id);
--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: users_tokens users_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users_tokens
ADD CONSTRAINT users_tokens_pkey PRIMARY KEY (id);
--
-- Name: pastes_belongs_to_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX pastes_belongs_to_index ON public.pastes USING btree (belongs_to);
--
-- Name: users_email_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX users_email_index ON public.users USING btree (email);
--
-- Name: users_tokens_context_token_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX users_tokens_context_token_index ON public.users_tokens USING btree (context, token);
--
-- Name: users_tokens_user_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX users_tokens_user_id_index ON public.users_tokens USING btree (user_id);
--
-- Name: pastes pastes_belongs_to_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.pastes
ADD CONSTRAINT pastes_belongs_to_fkey FOREIGN KEY (belongs_to) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- Name: users_tokens users_tokens_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users_tokens
ADD CONSTRAINT users_tokens_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--
INSERT INTO public."schema_migrations" (version) VALUES (20210811065554);
INSERT INTO public."schema_migrations" (version) VALUES (20210811213141);