code.vegaprotocol.io/vega@v0.79.0/datanode/sqlstore/migrations/0119_allowed_empty_amm_levels.sql (about)

     1  -- +goose Up
     2  
     3  ALTER TABLE markets ADD COLUMN IF NOT EXISTS allowed_empty_amm_levels INT default 0;
     4  ALTER TABLE markets_current ADD COLUMN IF NOT EXISTS allowed_empty_amm_levels INT default 0;
     5  
     6  -- +goose StatementBegin
     7  CREATE OR REPLACE FUNCTION update_current_markets()
     8      RETURNS TRIGGER
     9      LANGUAGE PLPGSQL AS
    10  $$
    11  BEGIN
    12  INSERT INTO markets_current(id,tx_hash,vega_time,instrument_id,tradable_instrument,decimal_places,fees,opening_auction,price_monitoring_settings,liquidity_monitoring_parameters,trading_mode,state,market_timestamps,position_decimal_places,lp_price_range, linear_slippage_factor, quadratic_slippage_factor, parent_market_id, insurance_pool_fraction, liquidity_sla_parameters, liquidation_strategy, mark_price_configuration, tick_size, enable_tx_reordering, allowed_empty_amm_levels)
    13  VALUES (NEW.id,NEW.tx_hash,NEW.vega_time,NEW.instrument_id,NEW.tradable_instrument,NEW.decimal_places,NEW.fees,NEW.opening_auction,NEW.price_monitoring_settings,NEW.liquidity_monitoring_parameters,NEW.trading_mode,NEW.state,NEW.market_timestamps,NEW.position_decimal_places,NEW.lp_price_range, NEW.linear_slippage_factor, NEW.quadratic_slippage_factor, NEW.parent_market_id, NEW.insurance_pool_fraction, NEW.liquidity_sla_parameters, NEW.liquidation_strategy, NEW.mark_price_configuration, NEW.tick_size, NEW.enable_tx_reordering, NEW.allowed_empty_amm_levels)
    14      ON CONFLICT(id) DO UPDATE SET
    15      tx_hash=EXCLUDED.tx_hash,
    16                             instrument_id=EXCLUDED.instrument_id,
    17                             tradable_instrument=EXCLUDED.tradable_instrument,
    18                             decimal_places=EXCLUDED.decimal_places,
    19                             fees=EXCLUDED.fees,
    20                             opening_auction=EXCLUDED.opening_auction,
    21                             price_monitoring_settings=EXCLUDED.price_monitoring_settings,
    22                             liquidity_monitoring_parameters=EXCLUDED.liquidity_monitoring_parameters,
    23                             trading_mode=EXCLUDED.trading_mode,
    24                             state=EXCLUDED.state,
    25                             market_timestamps=EXCLUDED.market_timestamps,
    26                             position_decimal_places=EXCLUDED.position_decimal_places,
    27                             lp_price_range=EXCLUDED.lp_price_range,
    28                             linear_slippage_factor=EXCLUDED.linear_slippage_factor,
    29                             quadratic_slippage_factor=EXCLUDED.quadratic_slippage_factor,
    30                             vega_time=EXCLUDED.vega_time,
    31                             parent_market_id=EXCLUDED.parent_market_id,
    32                             insurance_pool_fraction=EXCLUDED.insurance_pool_fraction,
    33                             liquidity_sla_parameters=EXCLUDED.liquidity_sla_parameters,
    34                             liquidation_strategy=EXCLUDED.liquidation_strategy,
    35                             mark_price_configuration=EXCLUDED.mark_price_configuration,
    36                             tick_size=EXCLUDED.tick_size,
    37                             enable_tx_reordering=EXCLUDED.enable_tx_reordering,
    38                             allowed_empty_amm_levels=EXCLUDED.allowed_empty_amm_levels;
    39  RETURN NULL;
    40  END;
    41  $$;
    42  -- +goose StatementEnd
    43  
    44  
    45  -- +goose Down
    46  ALTER TABLE markets DROP COLUMN IF EXISTS allowed_empty_amm_levels;
    47  ALTER TABLE markets_current DROP COLUMN IF EXISTS allowed_empty_amm_levels;
    48  
    49  -- +goose StatementBegin
    50  CREATE OR REPLACE FUNCTION update_current_markets()
    51      RETURNS TRIGGER
    52      LANGUAGE PLPGSQL AS
    53  $$
    54  BEGIN
    55  INSERT INTO markets_current(id,tx_hash,vega_time,instrument_id,tradable_instrument,decimal_places,fees,opening_auction,price_monitoring_settings,liquidity_monitoring_parameters,trading_mode,state,market_timestamps,position_decimal_places,lp_price_range, linear_slippage_factor, quadratic_slippage_factor, parent_market_id, insurance_pool_fraction, liquidity_sla_parameters, liquidation_strategy, mark_price_configuration, tick_size, enable_tx_reordering)
    56  VALUES (NEW.id,NEW.tx_hash,NEW.vega_time,NEW.instrument_id,NEW.tradable_instrument,NEW.decimal_places,NEW.fees,NEW.opening_auction,NEW.price_monitoring_settings,NEW.liquidity_monitoring_parameters,NEW.trading_mode,NEW.state,NEW.market_timestamps,NEW.position_decimal_places,NEW.lp_price_range, NEW.linear_slippage_factor, NEW.quadratic_slippage_factor, NEW.parent_market_id, NEW.insurance_pool_fraction, NEW.liquidity_sla_parameters, NEW.liquidation_strategy, NEW.mark_price_configuration, NEW.tick_size, NEW.enable_tx_reordering)
    57      ON CONFLICT(id) DO UPDATE SET
    58      tx_hash=EXCLUDED.tx_hash,
    59                             instrument_id=EXCLUDED.instrument_id,
    60                             tradable_instrument=EXCLUDED.tradable_instrument,
    61                             decimal_places=EXCLUDED.decimal_places,
    62                             fees=EXCLUDED.fees,
    63                             opening_auction=EXCLUDED.opening_auction,
    64                             price_monitoring_settings=EXCLUDED.price_monitoring_settings,
    65                             liquidity_monitoring_parameters=EXCLUDED.liquidity_monitoring_parameters,
    66                             trading_mode=EXCLUDED.trading_mode,
    67                             state=EXCLUDED.state,
    68                             market_timestamps=EXCLUDED.market_timestamps,
    69                             position_decimal_places=EXCLUDED.position_decimal_places,
    70                             lp_price_range=EXCLUDED.lp_price_range,
    71                             linear_slippage_factor=EXCLUDED.linear_slippage_factor,
    72                             quadratic_slippage_factor=EXCLUDED.quadratic_slippage_factor,
    73                             vega_time=EXCLUDED.vega_time,
    74                             parent_market_id=EXCLUDED.parent_market_id,
    75                             insurance_pool_fraction=EXCLUDED.insurance_pool_fraction,
    76                             liquidity_sla_parameters=EXCLUDED.liquidity_sla_parameters,
    77                             liquidation_strategy=EXCLUDED.liquidation_strategy,
    78                             mark_price_configuration=EXCLUDED.mark_price_configuration,
    79                             tick_size=EXCLUDED.tick_size,
    80                             enable_tx_reordering=EXCLUDED.enable_tx_reordering;
    81  RETURN NULL;
    82  END;
    83  $$;
    84  -- +goose StatementEnd