Skip to content

Commit

Permalink
Merge pull request #4075 from mathesar-foundation/generated_id_examples
Browse files Browse the repository at this point in the history
Generated Identity for example datasets
  • Loading branch information
Anish9901 authored Dec 13, 2024
2 parents b928de2 + 4eb2a62 commit c9d036f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 262 deletions.
101 changes: 21 additions & 80 deletions mathesar/examples/resources/library_without_checkouts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ CREATE TABLE "Authors" (
"Website" mathesar_types.uri
);

CREATE SEQUENCE "Authors_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Authors_id_seq" OWNED BY "Authors".id;
ALTER TABLE "Authors" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Authors_id_seq"
);


-- Books
Expand All @@ -34,15 +28,9 @@ CREATE TABLE "Books" (
"Publisher" integer
);

CREATE SEQUENCE "Books_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Books_id_seq" OWNED BY "Books".id;
ALTER TABLE "Books" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Books_id_seq"
);


-- Checkouts
Expand All @@ -56,15 +44,9 @@ CREATE TABLE "Checkouts" (
"Check In Time" timestamp without time zone
);

CREATE SEQUENCE "Checkouts_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Checkouts_id_seq" OWNED BY "Checkouts".id;
ALTER TABLE "Checkouts" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Checkouts_id_seq"
);


-- Items
Expand All @@ -78,15 +60,9 @@ CREATE TABLE "Items" (
);


CREATE SEQUENCE "Items_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Items_id_seq" OWNED BY "Items".id;
ALTER TABLE "Items" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Items_id_seq"
);


-- Media
Expand All @@ -96,15 +72,9 @@ CREATE TABLE "Media" (
"Type" text
);

CREATE SEQUENCE "Media_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Media_id_seq" OWNED BY "Media".id;
ALTER TABLE "Media" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Media_id_seq"
);


-- Patrons
Expand All @@ -116,15 +86,9 @@ CREATE TABLE "Patrons" (
"Email" mathesar_types.email
);

CREATE SEQUENCE "Patrons_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Patrons_id_seq" OWNED BY "Patrons".id;
ALTER TABLE "Patrons" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Patrons_id_seq"
);


-- Publishers
Expand All @@ -134,32 +98,9 @@ CREATE TABLE "Publishers" (
"Name" text
);

CREATE SEQUENCE "Publishers_id_seq"
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

ALTER SEQUENCE "Publishers_id_seq" OWNED BY "Publishers".id;


-- Set up defaults
ALTER TABLE ONLY "Authors"
ALTER COLUMN id SET DEFAULT nextval('"Authors_id_seq"'::regclass);
ALTER TABLE ONLY "Books"
ALTER COLUMN id SET DEFAULT nextval('"Books_id_seq"'::regclass);
ALTER TABLE ONLY "Checkouts"
ALTER COLUMN id SET DEFAULT nextval('"Checkouts_id_seq"'::regclass);
ALTER TABLE ONLY "Items"
ALTER COLUMN id SET DEFAULT nextval('"Items_id_seq"'::regclass);
ALTER TABLE ONLY "Media"
ALTER COLUMN id SET DEFAULT nextval('"Media_id_seq"'::regclass);
ALTER TABLE ONLY "Patrons"
ALTER COLUMN id SET DEFAULT nextval('"Patrons_id_seq"'::regclass);
ALTER TABLE ONLY "Publishers"
ALTER COLUMN id SET DEFAULT nextval('"Publishers_id_seq"'::regclass);
ALTER TABLE "Publishers" ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME "Publishers_id_seq"
);

--
-- Data for Name: Authors; Type: TABLE DATA; Schema: Library Management; Owner: -
Expand Down
Loading

0 comments on commit c9d036f

Please sign in to comment.