Skip to content

Commit

Permalink
Change inline default sequence nextval to explicit from migration
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Aug 29, 2017
1 parent fb55d3e commit 250aa32
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions db/migrations/deploy/0000000002-api_core.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE SCHEMA util;
SET search_path = api, pg_catalog;

CREATE TABLE client (
id integer DEFAULT nextval('client_id_seq'::regclass) NOT NULL,
id integer NOT NULL,
name text NOT NULL,
address text,
user_id integer DEFAULT request.user_id() NOT NULL,
Expand All @@ -18,7 +18,7 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE client TO api;
ALTER TABLE client ENABLE ROW LEVEL SECURITY;

CREATE TABLE project_comment (
id integer DEFAULT nextval('project_comment_id_seq'::regclass) NOT NULL,
id integer NOT NULL,
body text NOT NULL,
project_id integer NOT NULL,
user_id integer DEFAULT request.user_id() NOT NULL,
Expand All @@ -31,7 +31,7 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE project_comment TO api;
ALTER TABLE project_comment ENABLE ROW LEVEL SECURITY;

CREATE TABLE task_comment (
id integer DEFAULT nextval('task_comment_id_seq'::regclass) NOT NULL,
id integer NOT NULL,
body text NOT NULL,
task_id integer NOT NULL,
user_id integer DEFAULT request.user_id() NOT NULL,
Expand All @@ -44,7 +44,7 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE task_comment TO api;
ALTER TABLE task_comment ENABLE ROW LEVEL SECURITY;

CREATE TABLE project (
id integer DEFAULT nextval('project_id_seq'::regclass) NOT NULL,
id integer NOT NULL,
name text NOT NULL,
client_id integer NOT NULL,
user_id integer DEFAULT request.user_id() NOT NULL,
Expand All @@ -57,7 +57,7 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE project TO api;
ALTER TABLE project ENABLE ROW LEVEL SECURITY;

CREATE TABLE task (
id integer DEFAULT nextval('task_id_seq'::regclass) NOT NULL,
id integer NOT NULL,
name text NOT NULL,
completed boolean DEFAULT false NOT NULL,
project_id integer NOT NULL,
Expand Down Expand Up @@ -202,6 +202,16 @@ ALTER SEQUENCE task_comment_id_seq
ALTER SEQUENCE task_id_seq
OWNED BY task.id;

ALTER TABLE ONLY client ALTER COLUMN id SET DEFAULT nextval('client_id_seq'::regclass);

ALTER TABLE ONLY project_comment ALTER COLUMN id SET DEFAULT nextval('project_comment_id_seq'::regclass);

ALTER TABLE ONLY project ALTER COLUMN id SET DEFAULT nextval('project_id_seq'::regclass);

ALTER TABLE ONLY task_comment ALTER COLUMN id SET DEFAULT nextval('task_comment_id_seq'::regclass);

ALTER TABLE ONLY task ALTER COLUMN id SET DEFAULT nextval('task_id_seq'::regclass);

ALTER TABLE client
ADD CONSTRAINT client_pkey PRIMARY KEY (id);

Expand Down

0 comments on commit 250aa32

Please sign in to comment.