add
This commit is contained in:
@@ -39,6 +39,25 @@ BEGIN
|
|||||||
RAISE NOTICE 'exchange_name table already exists';
|
RAISE NOTICE 'exchange_name table already exists';
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'exchange_short_name') THEN
|
||||||
|
CREATE TABLE exchange_short_name (
|
||||||
|
id UUID DEFAULT gen_random_uuid_v7() PRIMARY KEY NOT NULL,
|
||||||
|
exchange_id UUID NOT NULL,
|
||||||
|
short_name VARCHAR NOT NULL,
|
||||||
|
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
CREATE TRIGGER update_short_name_updated_at
|
||||||
|
BEFORE UPDATE ON "exchange_short_name"
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION update_data_modified_column();
|
||||||
|
|
||||||
|
RAISE NOTICE 'created exchange_short_name table and trigger';
|
||||||
|
ELSE
|
||||||
|
RAISE NOTICE 'exchange_short_name table already exists';
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'exchange_code') THEN
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'exchange_code') THEN
|
||||||
CREATE TABLE exchange_code (
|
CREATE TABLE exchange_code (
|
||||||
id UUID DEFAULT gen_random_uuid_v7() PRIMARY KEY NOT NULL,
|
id UUID DEFAULT gen_random_uuid_v7() PRIMARY KEY NOT NULL,
|
||||||
@@ -74,12 +93,15 @@ BEGIN
|
|||||||
SELECT
|
SELECT
|
||||||
u.id AS exchange_id,
|
u.id AS exchange_id,
|
||||||
n.name AS name,
|
n.name AS name,
|
||||||
|
sn.short_name AS short_name,
|
||||||
c.code AS code,
|
c.code AS code,
|
||||||
u.deleted AS deleted
|
u.deleted AS deleted
|
||||||
FROM
|
FROM
|
||||||
exchange u
|
exchange u
|
||||||
JOIN
|
JOIN
|
||||||
exchange_name n ON u.id = n.exchange_id
|
exchange_name n ON u.id = n.exchange_id
|
||||||
|
JOIN
|
||||||
|
exchange_short_name sn ON u.id = sn.exchange_id
|
||||||
JOIN
|
JOIN
|
||||||
exchange_code c ON u.id = c.exchange_id
|
exchange_code c ON u.id = c.exchange_id
|
||||||
WHERE
|
WHERE
|
||||||
|
|||||||
Reference in New Issue
Block a user