aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/schema/postgresql_specific_schema.rb
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2012-04-27 22:53:07 -0400
committerPrem Sichanugrist <s@sikachu.com>2012-04-27 22:58:04 -0400
commit5156110476575f1b26be0b204ab2e12d2dd37434 (patch)
tree19315161ecff6bd840e92c3d74642db9833353eb /activerecord/test/schema/postgresql_specific_schema.rb
parent47a87fb0ec9d2e65914ff94abf2e5428d760fa39 (diff)
downloadrails-5156110476575f1b26be0b204ab2e12d2dd37434.tar.gz
rails-5156110476575f1b26be0b204ab2e12d2dd37434.tar.bz2
rails-5156110476575f1b26be0b204ab2e12d2dd37434.zip
Create plpgsql language if not available
This should fix the problem in Travis CI server. (http://travis-ci.org/#!/rails/rails/jobs/1194988)
Diffstat (limited to 'activerecord/test/schema/postgresql_specific_schema.rb')
-rw-r--r--activerecord/test/schema/postgresql_specific_schema.rb50
1 files changed, 29 insertions, 21 deletions
diff --git a/activerecord/test/schema/postgresql_specific_schema.rb b/activerecord/test/schema/postgresql_specific_schema.rb
index 84228cdd0a..e51db50ae3 100644
--- a/activerecord/test/schema/postgresql_specific_schema.rb
+++ b/activerecord/test/schema/postgresql_specific_schema.rb
@@ -127,28 +127,36 @@ _SQL
);
_SQL
- execute <<_SQL
- CREATE TABLE postgresql_partitioned_table_parent (
- id SERIAL PRIMARY KEY,
- number integer
- );
- CREATE TABLE postgresql_partitioned_table ( )
- INHERITS (postgresql_partitioned_table_parent);
-
- CREATE OR REPLACE FUNCTION partitioned_insert_trigger()
- RETURNS TRIGGER AS $$
- BEGIN
- INSERT INTO postgresql_partitioned_table VALUES (NEW.*);
- RETURN NULL;
- END;
- $$
- LANGUAGE plpgsql;
-
- CREATE TRIGGER insert_partitioning_trigger
- BEFORE INSERT ON postgresql_partitioned_table_parent
- FOR EACH ROW EXECUTE PROCEDURE partitioned_insert_trigger();
+begin
+ execute <<_SQL
+ CREATE TABLE postgresql_partitioned_table_parent (
+ id SERIAL PRIMARY KEY,
+ number integer
+ );
+ CREATE TABLE postgresql_partitioned_table ( )
+ INHERITS (postgresql_partitioned_table_parent);
+
+ CREATE OR REPLACE FUNCTION partitioned_insert_trigger()
+ RETURNS TRIGGER AS $$
+ BEGIN
+ INSERT INTO postgresql_partitioned_table VALUES (NEW.*);
+ RETURN NULL;
+ END;
+ $$
+ LANGUAGE plpgsql;
+
+ CREATE TRIGGER insert_partitioning_trigger
+ BEFORE INSERT ON postgresql_partitioned_table_parent
+ FOR EACH ROW EXECUTE PROCEDURE partitioned_insert_trigger();
_SQL
-
+rescue ActiveRecord::StatementInvalid => e
+ if e.message =~ /language "plpgsql" does not exist/
+ execute "CREATE LANGUAGE 'plpgsql';"
+ retry
+ else
+ raise e
+ end
+end
begin
execute <<_SQL