Comments (6)
Are you able to reproduce the problem in psql
?
Looking at Run()
in the postgres DB driver, the raw SQL statements are run from the migration file w/o any transforms, so it's unlikely that the problem is due to migrate
from migrate.
I had to place the whole function in a single line and parse it by \n
. Please add some kind of annotation like goose does for solving the same problem.
from migrate.
To be clear, migrate
migration files do not contain annotations, are not interpreted by migrate
, and are passed unmodified to the DB driver, which should be executing the migration with the DB.
I'm not sure what your problem was, but it seems like your migration file had some type of error in it or was malformed.
I didn't have any issues running this migration set (up and down) with migrate
3.2.0 and postgres 10:
Up:
create table "test_function" (
name VARCHAR(126)
);
create or replace function update_tsvector() returns trigger
as $update_tsvector$
begin
UPDATE test_function SET tsv = setweight(to_tsvector(name), 'A');
RETURN NULL;
end;
$update_tsvector$ LANGUAGE plpgsql;
CREATE TRIGGER update_tsvector
AFTER INSERT OR update of name ON test_function
FOR EACH ROW EXECUTE PROCEDURE update_tsvector();
Down:
DROP TRIGGER IF EXISTS "update_tsvector" ON "test_function";
DROP FUNCTION IF EXISTS "update_tsvector";
DROP TABLE IF EXISTS "test_function";
If there's a bug or usability issue w/ migrate
, we should address that, but that doesn't seem to be the case. Please correct me if I'm mistaken.
from migrate.
Closing due to inactivity. Please reopen if there's an issue with migrate
itself.
from migrate.
@dhui I'm seeing error pq: unterminated dollar-quoted string at or near "$$
when running this migration:
CREATE OR REPLACE FUNCTION some_func(param text)
RETURNS integer AS $$
BEGIN
INSERT into my_table (my_column) VALUES (param) ON CONFLICT DO NOTHING;
RETURN (SELECT id FROM my_table where my_column = param);
END;
$$ LANGUAGE plpgsql;
The driver is postgres
and I'm instantiating a new migrate client like this:
migrate.New("file://pathToMigrations", "postgres://user:password@hostname:port")
i'm using postgres 9.5 and this version of migrate:
github.com/golang-migrate/migrate/v4 v4.14.2-0.20210203071828-a185b9e78f19
Any ideas?
from migrate.
@andream16 are you able to reproduce the issue using postgres directly? Or using pq directly?
With multi-statements disable, you can see that the migration file contents is passed unmodified to postgres via lib/pq
from migrate.
Related Issues (20)
- Cloud Spanner using Google SQL: ON DELETE NO ACTION is not supported HOT 1
- Migrations that begin with the year 2024 fail during the 'up' migration process HOT 7
- How to run up/down migration before service starts?
- pgx not following intended import behaviour HOT 1
- Unable to change delimiter in mysql migrations HOT 1
- Support for libsql and Turso HOT 1
- "unexpected EOF" when connecting to MySQL DB via cloud-sql-proxy in github actions
- clickhouse TLS support is missing fir https://github.com/golang-migrate/migrate/blob/master/database/clickhouse/clickhouse.go
- Maintainer support for PR Backlog
- Allow users to fail when there are bad migration paths in their source HOT 3
- Expensive SQL query inside ensureVersionTable & ensureLockTable
- imported mongo official driver is out of date
- `Dirty database version 1. Fix and force version` and `error: can't read limit argument N` HOT 2
- SQLite3 accepts file URL with prefix `file:///`, but golang-migrate requires prefix `sqlite3:///`. Not flexible. HOT 1
- Do not return an error when no change. Communicate error conditions using errors.
- golang-migrate ignores PostgresSQL message reporting
- error: no migration found for version X (some numbers) HOT 1
- Cassandra multiple hosts cluster migrations failed HOT 1
- Install on Ubuntu with apt HOT 1
- Postgres / SQL multistatement support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from migrate.