提交 51561104 编写于 作者: P Prem Sichanugrist

Create plpgsql language if not available

This should fix the problem in Travis CI server.
(http://travis-ci.org/#!/rails/rails/jobs/1194988)
上级 47a87fb0
...@@ -127,28 +127,36 @@ ...@@ -127,28 +127,36 @@
); );
_SQL _SQL
execute <<_SQL begin
CREATE TABLE postgresql_partitioned_table_parent ( execute <<_SQL
id SERIAL PRIMARY KEY, CREATE TABLE postgresql_partitioned_table_parent (
number integer id SERIAL PRIMARY KEY,
); number integer
CREATE TABLE postgresql_partitioned_table ( ) );
INHERITS (postgresql_partitioned_table_parent); CREATE TABLE postgresql_partitioned_table ( )
INHERITS (postgresql_partitioned_table_parent);
CREATE OR REPLACE FUNCTION partitioned_insert_trigger()
RETURNS TRIGGER AS $$ CREATE OR REPLACE FUNCTION partitioned_insert_trigger()
BEGIN RETURNS TRIGGER AS $$
INSERT INTO postgresql_partitioned_table VALUES (NEW.*); BEGIN
RETURN NULL; INSERT INTO postgresql_partitioned_table VALUES (NEW.*);
END; RETURN NULL;
$$ END;
LANGUAGE plpgsql; $$
LANGUAGE plpgsql;
CREATE TRIGGER insert_partitioning_trigger
BEFORE INSERT ON postgresql_partitioned_table_parent CREATE TRIGGER insert_partitioning_trigger
FOR EACH ROW EXECUTE PROCEDURE partitioned_insert_trigger(); BEFORE INSERT ON postgresql_partitioned_table_parent
FOR EACH ROW EXECUTE PROCEDURE partitioned_insert_trigger();
_SQL _SQL
rescue ActiveRecord::StatementInvalid => e
if e.message =~ /language "plpgsql" does not exist/
execute "CREATE LANGUAGE 'plpgsql';"
retry
else
raise e
end
end
begin begin
execute <<_SQL execute <<_SQL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册