Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration: validation against schema fails with SQLite with tables that contain UUID columns #180

Open
YPares opened this issue Sep 27, 2022 · 1 comment

Comments

@YPares
Copy link
Contributor

YPares commented Sep 27, 2022

With selda-sqlite (v0.5.2.0), I'm getting errors with this kind of setup:

migrateUuidTableTest = do
  tryDropTable migrationUuid1
  createTable migrationUuid1
  insert_ migrationUuid1 [Only nil]
  autoMigrate False stepsUuid
  res <- query $ do
    select migrationUuid2
  assEq "migration went wrong" [nil] (fmap snd res)

migrationUuid1 :: Table (Only UUID)
migrationUuid1 = table "tableUuid" [Single mtUuid1_1 :- primary]
mtUuid1_1 = selectors migrationUuid1

migrationUuid2 :: Table (Text, UUID)
migrationUuid2 = table "tableUuid" [Single mtUuid2_1 :- primary]
mtUuid2_1 :*: mtUuid2_2 = selectors migrationUuid2

stepsUuid =
  [ [] --- AAA
  , [Migration migrationUuid1 migrationUuid2 $ \foo -> pure $ new
      [ mtUuid2_1 := toString (the foo)
      , mtUuid2_2 := the foo
      ]
    ]
  ] 

Depending on whether the AAA line above is there or not, I'm getting either

ValidationError "error validating table \"tableUuid\":\ntable has inconsistent columns:\n  \"col_0\":\n    column should have type `TUUID', but actually has type `TBlob' in database\n"

or just

ValidationError "no starting state matches the current state of the database"

but both seem to point at a problem re. how selda-sqlite deals with UUIDs when validating the schemas.

@YPares YPares changed the title Migration fails with SQLite in tables that contain UUID columns Migration: validation against schema fails with SQLite in tables that contain UUID columns Sep 27, 2022
@YPares YPares changed the title Migration: validation against schema fails with SQLite in tables that contain UUID columns Migration: validation against schema fails with SQLite with tables that contain UUID columns Sep 27, 2022
@YPares
Copy link
Contributor Author

YPares commented Sep 27, 2022

I opened an MR with a new test that exhibits that: #181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant