mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00

* feat(citext): implement citext for postgres * feat(citext): add citext -> String conversion test * feat(citext): fix ltree -> citree * feat(citext): add citext to the setup.sql * chore: address nits to #2478 * Rename `PgCitext` to `PgCiText` * Document when use of `PgCiText` is warranted * Document potentially surprising `PartialEq` behavior * Test that the macros consider `CITEXT` to be compatible with `String` and friends * doc: add `PgCiText` to `postgres::types` listing * chore: restore missing trailing line break to `tests/postgres/setup.sql` --------- Co-authored-by: Austin Bonander <austin@launchbadge.com>
54 lines
1.3 KiB
PL/PgSQL
54 lines
1.3 KiB
PL/PgSQL
-- https://www.postgresql.org/docs/current/ltree.html
|
|
CREATE EXTENSION IF NOT EXISTS ltree;
|
|
|
|
-- https://www.postgresql.org/docs/current/citext.html
|
|
CREATE EXTENSION IF NOT EXISTS citext;
|
|
|
|
-- https://www.postgresql.org/docs/current/sql-createtype.html
|
|
CREATE TYPE status AS ENUM ('new', 'open', 'closed');
|
|
|
|
-- https://www.postgresql.org/docs/current/rowtypes.html#ROWTYPES-DECLARING
|
|
CREATE TYPE inventory_item AS
|
|
(
|
|
name TEXT,
|
|
supplier_id INT,
|
|
price BIGINT
|
|
);
|
|
|
|
-- https://github.com/prisma/database-schema-examples/tree/master/postgres/basic-twitter#basic-twitter
|
|
CREATE TABLE tweet
|
|
(
|
|
id BIGSERIAL PRIMARY KEY,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
text TEXT NOT NULL,
|
|
owner_id BIGINT
|
|
);
|
|
|
|
CREATE TABLE tweet_reply
|
|
(
|
|
id BIGSERIAL PRIMARY KEY,
|
|
tweet_id BIGINT NOT NULL REFERENCES tweet(id),
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
text TEXT NOT NULL,
|
|
owner_id BIGINT
|
|
);
|
|
|
|
CREATE TYPE float_range AS RANGE
|
|
(
|
|
subtype = float8,
|
|
subtype_diff = float8mi
|
|
);
|
|
|
|
CREATE TABLE products (
|
|
product_no INTEGER,
|
|
name TEXT,
|
|
price NUMERIC CHECK (price > 0)
|
|
);
|
|
|
|
CREATE OR REPLACE PROCEDURE forty_two(INOUT forty_two INT = NULL)
|
|
LANGUAGE plpgsql AS 'begin forty_two := 42; end;';
|
|
|
|
CREATE TABLE test_citext (
|
|
foo CITEXT NOT NULL
|
|
);
|