frac-foreigner 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,21 @@ module Foreigner
|
|
23
23
|
execute "ALTER TABLE #{table} DROP CONSTRAINT #{constraint_name}"
|
24
24
|
end
|
25
25
|
|
26
|
+
def pk(table_name)
|
27
|
+
pk_info = select_all %{
|
28
|
+
select c.COLUMN_NAME as pk
|
29
|
+
from INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk, INFORMATION_SCHEMA.KEY_COLUMN_USAGE c
|
30
|
+
where pk.TABLE_NAME = '#{table_name}'
|
31
|
+
and CONSTRAINT_TYPE = 'PRIMARY KEY'
|
32
|
+
and c.TABLE_NAME = pk.TABLE_NAME
|
33
|
+
and c.CONSTRAINT_NAME = pk.CONSTRAINT_NAME
|
34
|
+
}
|
35
|
+
pk_info.map do |row|
|
36
|
+
options = {:pk => row['pk']}
|
37
|
+
options
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
26
41
|
def foreign_keys(table_name)
|
27
42
|
fk_info = select_all %{
|
28
43
|
SELECT tc.constraint_name as name
|