add
This commit is contained in:
@@ -55,4 +55,40 @@ BEGIN
|
|||||||
ELSE
|
ELSE
|
||||||
RAISE NOTICE 'variety_code table already exists';
|
RAISE NOTICE 'variety_code table already exists';
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'variety_tick') THEN
|
||||||
|
CREATE TABLE variety_tick (
|
||||||
|
id UUID DEFAULT gen_random_uuid_v7() PRIMARY KEY NOT NULL,
|
||||||
|
tick NUMERIC(12, 6),
|
||||||
|
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_variety_tick_updated_at
|
||||||
|
BEFORE UPDATE ON "variety_tick"
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION update_data_modified_column();
|
||||||
|
|
||||||
|
RAISE NOTICE 'created variety_tick table and trigger';
|
||||||
|
ELSE
|
||||||
|
RAISE NOTICE 'variety_tick table already exists';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'variety_tick_price') THEN
|
||||||
|
CREATE TABLE variety_tick_price (
|
||||||
|
id UUID DEFAULT gen_random_uuid_v7() PRIMARY KEY NOT NULL,
|
||||||
|
price NUMERIC(12, 6),
|
||||||
|
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_variety_tick_price_updated_at
|
||||||
|
BEFORE UPDATE ON "variety_tick_price"
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION update_data_modified_column();
|
||||||
|
|
||||||
|
RAISE NOTICE 'created variety_tick_price table and trigger';
|
||||||
|
ELSE
|
||||||
|
RAISE NOTICE 'variety_tick_price table already exists';
|
||||||
|
END IF;
|
||||||
END $$;
|
END $$;
|
||||||
Reference in New Issue
Block a user