code.vegaprotocol.io/vega@v0.79.0/datanode/sqlstore/migrations/0027_add_rejection_reason_on_stop_orders.sql (about) 1 -- +goose Up 2 3 -- +goose StatementBegin 4 DO 5 $$ 6 BEGIN 7 IF NOT EXISTS (SELECT * FROM pg_type typ JOIN pg_namespace ns ON ns.oid = typ.typnamespace 8 WHERE ns.nspname = current_schema() AND typ.typname = 'stop_order_rejection_reason') 9 THEN 10 CREATE TYPE stop_order_rejection_reason as enum( 11 'REJECTION_REASON_UNSPECIFIED', 12 'REJECTION_REASON_TRADING_NOT_ALLOWED', 13 'REJECTION_REASON_EXPIRY_IN_THE_PAST', 14 'REJECTION_REASON_MUST_BE_REDUCE_ONLY', 15 'REJECTION_REASON_MAX_STOP_ORDERS_PER_PARTY_REACHED', 16 'REJECTION_REASON_STOP_ORDER_NOT_ALLOWED_WITHOUT_A_POSITION', 17 'REJECTION_REASON_STOP_ORDER_NOT_CLOSING_THE_POSITION'); 18 END IF; 19 END 20 $$; 21 -- +goose StatementEnd 22 23 ALTER TABLE stop_orders ADD COLUMN IF NOT EXISTS rejection_reason stop_order_rejection_reason NOT NULL DEFAULT 'REJECTION_REASON_UNSPECIFIED'; 24 25 -- +goose Down 26 27 -- Don't do anything, just leave the column there, the up script shouldn't add it if it already exists.