beam icon indicating copy to clipboard operation
beam copied to clipboard

`beam-migrate simple schema` fails on all but empty database

Open RichardWarfield opened this issue 7 years ago • 5 comments

Based on instructions at #27 I run stack exec -- beam-migrate simple schema --backend Database.Beam.Postgres.Migrate --connection "dbname=<my db> user=<my user> password=<my pw>" to create a schema from an existing database, but:

  • Running on my full (complex) postgres database results in beam-migrate occupying all available memory then coredumping.
  • Running on a test database with even one table results in beam-migrate: user error (Could not form haskell schema)
  • Running on a completely empty test database seems to work OK.

Using beam master branch and Postgresql 10.4 on Arch linux.

RichardWarfield avatar Jul 05 '18 07:07 RichardWarfield

What is the database schema?

tathougies avatar Jul 10 '18 18:07 tathougies

It fails even with something as simple as:

CREATE TABLE public.test_table ( );

ALTER TABLE public.test_table OWNER TO postgres;

This results in the Could not form haskell schema error.

RichardWarfield avatar Jul 11 '18 01:07 RichardWarfield

I am experiencing the same issue with current master (24a96f2f8d53558c33f1fe4031bd0687f9511e01):

$ stack exec -- beam-migrate simple schema --connection postgres://postgres@localhost:5432/postgres --backend Database.Beam.Postgres.Migrate
beam-migrate: user error (Could not form haskell schema)

Dump works however:

$ stack exec -- beam-migrate simple dump --connection postgres://postgres@localhost:5432/postgres --backend Database.Beam.Postgres.Migrate
- predicates:
  - has-column:
      type: int
      column: meh
      table: foo
  - table-exists: foo
  specificity:
  - backend: Database.Beam.Postgres.Migrate

PostgreSQL 10.6, with DDL:

create table foo (meh int);

awh avatar Jan 28 '19 14:01 awh

@tathougies I made an attempt at digging into this with Debug.Trace but foundered quickly on an inability to derive Show on most of the types used inside heuristicSolver. Any thoughts on how to debug?

awh avatar Jan 29 '19 14:01 awh

Which types in particular? You should be able to get away with the various debug functions in DatabasePredicate.

tathougies avatar Jan 31 '19 18:01 tathougies