Skip to content

Instantly share code, notes, and snippets.

@ashwoods
Last active April 26, 2018 12:33
Show Gist options
  • Save ashwoods/6973308 to your computer and use it in GitHub Desktop.
Save ashwoods/6973308 to your computer and use it in GitHub Desktop.
entry creation in transaction.
INSERT INTO "entries_entry" ("created",
"modified",
"award_id",
"category_id",
"user_id",
"status",
"status_changed",
"position",
"price",
"title")
VALUES ('2013-10-14 11:41:16.870857',
'2013-10-14 11:41:18.741761',
1,
5,
41,
'draft',
'2013-10-14 11:41:16.871015',
NULL,
NULL,
'boodsfd') RETURNING "entries_entry"."id" [0.66ms]
SELECT COUNT(*)
FROM "entries_entry"
WHERE ("entries_entry"."award_id" = 1
AND "entries_entry"."id" < 933) [1.04ms]
SELECT (1) AS "a"
FROM "entries_entry"
WHERE "entries_entry"."id" = 933 LIMIT 1 [0.56ms]
UPDATE "entries_entry"
SET "created" = '2013-10-14 11:41:16.870857',
"modified" = '2013-10-14 11:41:18.753804',
"award_id" = 1,
"category_id" = 5,
"user_id" = 41,
"status" = 'draft',
"status_changed" = '2013-10-14 11:41:16.871015',
"position" = 549,
"price" = NULL,
"title" = 'boodsfd'
WHERE "entries_entry"."id" = 933 [0.52ms]
Table -->
-- Table: entries_entry
-- DROP TABLE entries_entry;
CREATE TABLE entries_entry
(
id serial NOT NULL,
created timestamp with time zone NOT NULL,
modified timestamp with time zone NOT NULL,
award_id integer,
category_id integer,
user_id integer NOT NULL,
status character varying(100) NOT NULL,
status_changed timestamp with time zone NOT NULL,
"position" integer,
price double precision,
title character varying(100) NOT NULL,
CONSTRAINT entries_entry_pkey PRIMARY KEY (id),
CONSTRAINT award_id_refs_id_c9692926 FOREIGN KEY (award_id)
REFERENCES awards_award (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT category_id_refs_id_fc4765c2 FOREIGN KEY (category_id)
REFERENCES awards_category (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT user_id_refs_id_1a252400 FOREIGN KEY (user_id)
REFERENCES officium_officiumuser (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT entries_entry_position_597ecfb344af6b12_uniq UNIQUE ("position", award_id),
CONSTRAINT ck_position_pstv_1843974533670ec7 CHECK ("position" >= 0)
)
WITH (
OIDS=FALSE
);
ALTER TABLE entries_entry
OWNER TO nemesis;
-- Index: entries_entry_award_id
-- DROP INDEX entries_entry_award_id;
CREATE INDEX entries_entry_award_id
ON entries_entry
USING btree
(award_id);
-- Index: entries_entry_category_id
-- DROP INDEX entries_entry_category_id;
CREATE INDEX entries_entry_category_id
ON entries_entry
USING btree
(category_id);
-- Index: entries_entry_user_id
-- DROP INDEX entries_entry_user_id;
CREATE INDEX entries_entry_user_id
ON entries_entry
USING btree
(user_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment