@@ -222,36 +222,12 @@ def foreign_keys(table_name)
222222 end
223223 end
224224
225- # OVERRIDE: Verify that the related attribute to the unique_constraint is not dropped.
226- # See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/347.
225+ # OVERRIDE: UNIQUE CONSTRAINTS will create indexes anyway, so we only consider
226+ # then as indexes.
227+ # See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/347.
228+ # See https://www.cockroachlabs.com/docs/stable/unique
227229 def unique_constraints ( table_name )
228- scope = quoted_scope ( table_name )
229-
230- unique_info = internal_exec_query ( <<~SQL , "SCHEMA" , allow_retry : true , materialize_transactions : false )
231- SELECT c.conname, c.conrelid, c.conkey, c.condeferrable, c.condeferred
232- FROM pg_constraint c
233- JOIN pg_class t ON c.conrelid = t.oid
234- JOIN pg_namespace n ON n.oid = c.connamespace
235- JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = c.conkey[1] -- OVERRIDE
236- WHERE c.contype = 'u'
237- AND t.relname = #{ scope [ :name ] }
238- AND n.nspname = #{ scope [ :schema ] }
239- AND not a.attisdropped -- OVERRIDE
240- SQL
241-
242- unique_info . map do |row |
243- conkey = row [ "conkey" ] . delete ( "{}" ) . split ( "," ) . map ( &:to_i )
244- columns = column_names_from_column_numbers ( row [ "conrelid" ] , conkey )
245-
246- deferrable = extract_constraint_deferrable ( row [ "condeferrable" ] , row [ "condeferred" ] )
247-
248- options = {
249- name : row [ "conname" ] ,
250- deferrable : deferrable
251- }
252-
253- UniqueConstraintDefinition . new ( table_name , columns , options )
254- end
230+ [ ]
255231 end
256232
257233 # CockroachDB uses unique_rowid() for primary keys, not sequences. It's
0 commit comments