@@ -69,6 +69,10 @@ func TestTradeUpgradeScripts(t *testing.T) {
6969 DataType : "text" ,
7070 CharacterMaximumLength : nil ,
7171 }, & columns [4 ])
72+ // check indexes of db_version table
73+ indexes := database .GetTableIndexes (db , "db_version" )
74+ assert .Equal (t , 1 , len (indexes ))
75+ database .AssertIndex (t , "db_version" , "db_version_pkey" , "CREATE UNIQUE INDEX db_version_pkey ON public.db_version USING btree (version)" , indexes )
7276
7377 // check schema of markets table
7478 columns = database .GetTableSchema (db , "markets" )
@@ -105,6 +109,10 @@ func TestTradeUpgradeScripts(t *testing.T) {
105109 DataType : "text" ,
106110 CharacterMaximumLength : nil ,
107111 }, & columns [3 ])
112+ // check indexes of markets table
113+ indexes = database .GetTableIndexes (db , "markets" )
114+ assert .Equal (t , 1 , len (indexes ))
115+ database .AssertIndex (t , "markets" , "markets_pkey" , "CREATE UNIQUE INDEX markets_pkey ON public.markets USING btree (market_id)" , indexes )
108116
109117 // check schema of trades table
110118 columns = database .GetTableSchema (db , "trades" )
@@ -181,6 +189,11 @@ func TestTradeUpgradeScripts(t *testing.T) {
181189 DataType : "double precision" ,
182190 CharacterMaximumLength : nil ,
183191 }, & columns [8 ])
192+ // check indexes of trades table
193+ indexes = database .GetTableIndexes (db , "trades" )
194+ assert .Equal (t , 2 , len (indexes ))
195+ database .AssertIndex (t , "trades" , "trades_pkey" , "CREATE UNIQUE INDEX trades_pkey ON public.trades USING btree (market_id, txid)" , indexes )
196+ database .AssertIndex (t , "trades" , "trades_mdd" , "CREATE INDEX trades_mdd ON public.trades USING btree (market_id, date(date_utc), date_utc)" , indexes )
184197
185198 // check entries of db_version table
186199 var allRows [][]interface {}
@@ -189,7 +202,7 @@ func TestTradeUpgradeScripts(t *testing.T) {
189202 // first three code_version_string is nil becuase the field was not supported at the time when the upgrade script was run, and only in version 4 of
190203 // the database do we add the field. See upgradeScripts and RunUpgradeScripts() for more details
191204 database .ValidateDBVersionRow (t , allRows [0 ], 1 , time .Now (), 1 , 10 , nil )
192- database .ValidateDBVersionRow (t , allRows [1 ], 2 , time .Now (), 3 , 10 , nil )
205+ database .ValidateDBVersionRow (t , allRows [1 ], 2 , time .Now (), 3 , 15 , nil )
193206 database .ValidateDBVersionRow (t , allRows [2 ], 3 , time .Now (), 2 , 10 , nil )
194207 database .ValidateDBVersionRow (t , allRows [3 ], 4 , time .Now (), 1 , 10 , & codeVersionString )
195208
0 commit comments