OSDN Git Service

add support use string FK with integer PK
authorAndrey Kumanyaev <me@zzet.org>
Tue, 9 Oct 2012 23:31:51 +0000 (03:31 +0400)
committerAndrey Kumanyaev <me@zzet.org>
Tue, 9 Oct 2012 23:58:34 +0000 (03:58 +0400)
db/migrate/20121009205010_postgres_create_integer_cast.rb [new file with mode: 0644]

diff --git a/db/migrate/20121009205010_postgres_create_integer_cast.rb b/db/migrate/20121009205010_postgres_create_integer_cast.rb
new file mode 100644 (file)
index 0000000..b9a9713
--- /dev/null
@@ -0,0 +1,15 @@
+class PostgresCreateIntegerCast < ActiveRecord::Migration
+  def up
+    execute <<-SQL
+      CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT;
+    SQL
+    rescue ActiveRecord::StatementInvalid
+  end
+
+  def down
+    execute <<-SQL
+      DROP CAST (integer AS text);
+    SQL
+    rescue ActiveRecord::StatementInvalid
+  end
+end