Skip to content

Instantly share code, notes, and snippets.

@sleepingkingstudios
Created December 6, 2019 04:37
Show Gist options
  • Save sleepingkingstudios/29af5584cb7957de357b88604722ec83 to your computer and use it in GitHub Desktop.
Save sleepingkingstudios/29af5584cb7957de357b88604722ec83 to your computer and use it in GitHub Desktop.
ApplicationRecord.connection.execute(
<<~SQL
CREATE TEMPORARY TABLE IF NOT EXISTS gadgets
(
id bigint NOT NULL,
name varchar(64) NOT NULL
);
CREATE TEMPORARY SEQUENCE IF NOT EXISTS gadgets_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE gadgets_id_seq OWNED BY gadgets.id;
ALTER TABLE ONLY gadgets
ALTER COLUMN id
SET DEFAULT nextval('gadgets_id_seq'::regclass);
SQL
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment