Skip to content

Commit

Permalink
Separate schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jul 9, 2020
1 parent 6c1f672 commit d778493
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
24 changes: 24 additions & 0 deletions test/support/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SET client_min_messages = warning;

DROP TABLE IF EXISTS "Posts_intermediate" CASCADE;
DROP TABLE IF EXISTS "Posts" CASCADE;
DROP TABLE IF EXISTS "Posts_retired" CASCADE;
DROP FUNCTION IF EXISTS "Posts_insert_trigger"();
DROP TABLE IF EXISTS "Users" CASCADE;

CREATE TABLE "Users" (
"Id" SERIAL PRIMARY KEY
);

CREATE TABLE "Posts" (
"Id" SERIAL PRIMARY KEY,
"UserId" INTEGER,
"createdAt" timestamp,
"createdAtTz" timestamptz,
"createdOn" date,
CONSTRAINT "foreign_key_1" FOREIGN KEY ("UserId") REFERENCES "Users"("Id")
);

CREATE INDEX ON "Posts" ("createdAt");

INSERT INTO "Posts" ("createdAt", "createdAtTz", "createdOn") SELECT NOW(), NOW(), NOW() FROM generate_series(1, 10000) n;
22 changes: 1 addition & 21 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,4 @@

$url = ENV["PGSLICE_URL"] || "postgres:///pgslice_test"
$conn = PG::Connection.new($url)
$conn.exec <<-SQL
SET client_min_messages = warning;
DROP TABLE IF EXISTS "Posts_intermediate" CASCADE;
DROP TABLE IF EXISTS "Posts" CASCADE;
DROP TABLE IF EXISTS "Posts_retired" CASCADE;
DROP FUNCTION IF EXISTS "Posts_insert_trigger"();
DROP TABLE IF EXISTS "Users" CASCADE;
CREATE TABLE "Users" (
"Id" SERIAL PRIMARY KEY
);
CREATE TABLE "Posts" (
"Id" SERIAL PRIMARY KEY,
"UserId" INTEGER,
"createdAt" timestamp,
"createdAtTz" timestamptz,
"createdOn" date,
CONSTRAINT "foreign_key_1" FOREIGN KEY ("UserId") REFERENCES "Users"("Id")
);
CREATE INDEX ON "Posts" ("createdAt");
INSERT INTO "Posts" ("createdAt", "createdAtTz", "createdOn") SELECT NOW(), NOW(), NOW() FROM generate_series(1, 10000) n;
SQL
$conn.exec File.read("test/support/schema.sql")

0 comments on commit d778493

Please sign in to comment.