graphile/migrate

Does not point to the file containing the error

Nembus opened this issue ยท 5 comments

Summary

Instead, the script just mentions current.sql even if we're using current directory instead of current.sql

Steps to reproduce

Expected results

Actual results

Additional context

[2020-10-08T19:22:48.788Z]: Running current.sql

๐Ÿ›‘ Error occurred whilst processing migration
error: cannot drop function app_public.current_user_scope() because other objects depend on it
at Parser.parseErrorMessage (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket. (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:321:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:273:9)
at Socket.Readable.push (_stream_readable.js:214:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

(node:45201) UnhandledPromiseRejectionWarning: error: cannot drop function app_public.current_user_scope() because other objects depend on it
at Parser.parseErrorMessage (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket. (/Users/timmyk/code/graphql/Gel/@app/db/node_modules/pg-protocol/dist/index.js:10:42)
at Socket.emit (events.js:321:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:273:9)
at Socket.Readable.push (_stream_readable.js:214:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
(node:45201) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)

Possible Solution

I witnessed this over screen sharing ๐Ÿ‘

Reproduced with current.sql migration:

drop function if exists one();
create function one() returns int as $$
select 1;
$$ language sql stable;

drop table if exists foo;
create table foo (
  id serial primary key,
  number int not null default one()
);

drop function if exists one();
create function one() returns int as $$
  select 1;
$$ language sql stable;

I've fixed the unhandled promise rejection; that was a minor oversight in the watch code.

Unfortunately PostgreSQL does not give us enough information for us to know where this error originated within the document we've sent, which is unfortunate.

Screenshot_20201009_112733

(We need the position value to be specified.)

I've done the best I can with the information I have:

Screenshot_20201009_112926

(Fix is out in v1.0.2)