-
-
Save mewwts/704663e19a21bc51864f3298f09a18c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO foreign.labels (address, labels) | |
SELECT address_id, ARRAY_AGG(name) AS labels | |
FROM labels | |
GROUP BY 1 | |
LIMIT 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE labels ( | |
id integer NOT NULL, | |
address_id bytea NOT NULL, | |
name text NOT NULL, | |
author character varying(50) NOT NULL, | |
type text NOT NULL, | |
source text, | |
updated_at timestamp with time zone DEFAULT now() NOT NULL, | |
CONSTRAINT lowercase_name CHECK ((name = lower(name))), | |
CONSTRAINT lowercase_type CHECK ((type = lower(type))), | |
CONSTRAINT whitespace_name CHECK ((regexp_replace(btrim(name, ' '::text), '(\s+)'::text, ' '::text, 'g'::text) = name)), | |
CONSTRAINT whitespace_type CHECK ((regexp_replace(btrim(type, ' '::text), '(\s+)'::text, ' '::text, 'g'::text) = type)) | |
); | |
CREATE INDEX labels_label ON labels USING BTREE (name); | |
CREATE INDEX labels_label_type ON labels USING BTREE (type); | |
CREATE INDEX labels_address ON labels USING HASH (address_id); | |
CREATE INDEX labels_source ON labels USING BTREE (source); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE labels.labels ( | |
address bytea PRIMARY KEY, | |
labels text[] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment