frac-foreigner 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frac-foreigner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: