Comments (5)
@DavidWalter what version of FluentKit are you using? 1.21.0 contained a number of fixes for enums. If you're on the latest and still getting the error can you post the generated SQL from the migration?
from fluent-postgres-driver.
Hi thanks for your response!
Yes I'm on 1.21.0. See the whole Package.resolved here
Package.resolved.txt
(The "AddChoiceAndTextTaskTypes" is the real name of the "AddMoreTaskTypes" example above)
I run this migration which resulted in the logs below:
struct Migration2: AsyncMigration {
let name = "AddChoiceAndTextTaskTypes"
func prepare(on database: Database) async throws {
let taskTypes = try await database.enum(TaskType.schema)
.case(TaskType.singleChoice.rawValue)
.case(TaskType.multipleChoice.rawValue)
.update()
}
}
debug:
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql ALTER TABLE "ev_envelopes" ADD "assigned_user" UUID REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE []
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql query create _fluent_migrations input=[[id: 5176F3C5-4B71-4BF8-A159-2D256D83FDBE, created_at: 2022-02-22 09:57:38 +0000, name: "UpdateEnvelopeAssignedUser", batch: 1, updated_at: 2022-02-22 09:57:38 +0000]]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql INSERT INTO "_fluent_migrations" ("id", "created_at", "name", "batch", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [5176F3C5-4B71-4BF8-A159-2D256D83FDBE, 2022-02-22 09:57:38 +0000, "UpdateEnvelopeAssignedUser", 1, 2022-02-22 09:57:38 +0000]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql SQLAlterEnum(name: SQLKit.SQLIdentifier(string: "task_type"), value: Optional(SQLKit.SQLLiteral.string("multipleChoice")))
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql CREATE TABLE IF NOT EXISTS "_fluent_enums"("id" UUID PRIMARY KEY, "name" TEXT NOT NULL, "case" TEXT NOT NULL, CONSTRAINT "uq:_fluent_enums.name+_fluent_enums.case" UNIQUE ("name", "case")) []
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql query create _fluent_enums input=[[case: "singleChoice", id: 38FEEF01-0FC6-4955-A9FB-45322D8CEBA0, name: "task_type"], [id: 9AA05F25-2DD4-4E98-B0DF-A39704AF85AA, name: "task_type", case: "multipleChoice"]]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql INSERT INTO "_fluent_enums" ("case", "id", "name") VALUES ($1, $2, $3), ($4, $5, $6) RETURNING "id" ["singleChoice", 38FEEF01-0FC6-4955-A9FB-45322D8CEBA0, "task_type", "multipleChoice", 9AA05F25-2DD4-4E98-B0DF-A39704AF85AA, "task_type"]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql query delete _fluent_enums filters=[_fluent_enums[name] = "task_type", _fluent_enums[case] ~~ []]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql DELETE FROM "_fluent_enums" WHERE "_fluent_enums"."name" = $1 AND 1 = 0 ["task_type"]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql Connection pool exhausted on this event loop, adding request to waitlist
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql Fulfilling connection waitlist request
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql query read _fluent_enums filters=[_fluent_enums[name] = "task_type"]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql SELECT "_fluent_enums"."id" AS "_fluent_enums_id", "_fluent_enums"."name" AS "_fluent_enums_name", "_fluent_enums"."case" AS "_fluent_enums_case" FROM "_fluent_enums" WHERE "_fluent_enums"."name" = $1 ["task_type"]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql query create _fluent_migrations input=[[id: 09E5C7D9-52CE-4158-979C-7C0AF85F99C3, created_at: 2022-02-22 09:57:38 +0000, name: "AddChoiceAndTextTaskTypes", batch: 1, updated_at: 2022-02-22 09:57:38 +0000]]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql INSERT INTO "_fluent_migrations" ("id", "created_at", "name", "batch", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [09E5C7D9-52CE-4158-979C-7C0AF85F99C3, 2022-02-22 09:57:38 +0000, "AddChoiceAndTextTaskTypes", 1, 2022-02-22 09:57:38 +0000]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql CREATE TABLE "ev_choice"("id" UUID PRIMARY KEY, "task_id" UUID REFERENCES "ev_tasks" ("id") ON DELETE CASCADE ON UPDATE CASCADE NOT NULL, "title" TEXT NOT NULL, "text_label" TEXT, "text_required" BOOL NOT NULL, "order" BIGINT NOT NULL) []
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql query create _fluent_migrations input=[[updated_at: 2022-02-22 09:57:38 +0000, name: "CreateChoice", batch: 1, id: 8B5883C8-80F7-4B37-9680-5F6F214CA336, created_at: 2022-02-22 09:57:38 +0000]]
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql INSERT INTO "_fluent_migrations" ("updated_at", "name", "batch", "id", "created_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [2022-02-22 09:57:38 +0000, "CreateChoice", 1, 8B5883C8-80F7-4B37-9680-5F6F214CA336, 2022-02-22 09:57:38 +0000]
trace:
2022-02-22T10:41:52+0100 trace codes.vapor.application : database-id=psql psql_connection_action=read psql_connection_id=C72FCB11-028F-4144-8D13-2A43DD282E39 Run action
2022-02-22T10:41:52+0100 debug codes.vapor.application : database-id=psql query create _fluent_migrations input=[[id: 12F63872-FC23-403A-8418-DF0D4A04A5D0, created_at: 2022-02-22 09:41:52 +0000, updated_at: 2022-02-22 09:41:52 +0000, batch: 1, name: "AddChoiceAndTextTaskTypes"]]
2022-02-22T10:41:52+0100 debug codes.vapor.application : database-id=psql INSERT INTO "_fluent_migrations" ("id", "created_at", "updated_at", "batch", "name") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [12F63872-FC23-403A-8418-DF0D4A04A5D0, 2022-02-22 09:41:52 +0000, 2022-02-22 09:41:52 +0000, 1, "AddChoiceAndTextTaskTypes"]
2022-02-22T10:41:52+0100 trace codes.vapor.application : database-id=psql Re-using available connection
2022-02-22T10:41:52+0100 trace codes.vapor.application : database-id=psql psql_connection_id=C72FCB11-028F-4144-8D13-2A43DD282E39 psql_connection_state=ConnectionStateMachine(state: .extendedQuery(PostgresNIO.ExtendedQueryStateMachine(state: PostgresNIO.ExtendedQueryStateMachine.State.parseDescribeBindExecuteSyncSent(PostgresNIO.ExtendedQueryContext)), connectionContext: (processID: 1248, secretKey: 0000000, parameters: ["application_name": "", "session_authorization": "heim_db_username", "integer_datetimes": "on", "is_superuser": "on", "standard_conforming_strings": "on", "TimeZone": "Etc/UTC", "server_version": "13.5 (Debian 13.5-1.pgdg110+1)", "client_encoding": "UTF8", "IntervalStyle": "postgres", "DateStyle": "ISO, MDY", "server_encoding": "UTF8"])), taskQueue: [ _ _ _ _ _ _ _ _ _ <_ _ _ _ _ _ _ ] (bufferCapacity: 16, ringLength: 0), quiescingState: .notQuiescing) Connection state changed
2022-02-22T10:41:52+0100 trace codes.vapor.application : database-id=psql psql_connection_action=sendParseDescribeBindExecuteSync(query: "INSERT INTO \"_fluent_migrations\" (\"id\", \"created_at\", \"updated_at\", \"batch\", \"name\") VALUES ($1, $2, $3, $4, $5) RETURNING \"id\"", binds: [12F63872-FC23-403A-8418-DF0D4A04A5D0, 2022-02-22 09:41:52 +0000, 2022-02-22 09:41:52 +0000, 1, "AddChoiceAndTextTaskTypes"]) psql_connection_id=C72FCB11-028F-4144-8D13-2A43DD282E39 Run action
2022-02-22T10:41:52+0100 trace codes.vapor.application : database-id=psql psql_connection_id=C72FCB11-028F-4144-8D13-2A43DD282E39 psql_message=.parseComplete Backend message received
Just let me know if you need more info.
from fluent-postgres-driver.
@DavidWalter can you check the DB after the migration? It looks like both options should be added
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql INSERT INTO "_fluent_enums" ("case", "id", "name") VALUES ($1, $2, $3), ($4, $5, $6) RETURNING "id" ["singleChoice", 38FEEF01-0FC6-4955-A9FB-45322D8CEBA0, "task_type", "multipleChoice", 9AA05F25-2DD4-4E98-B0DF-A39704AF85AA, "task_type"]
from fluent-postgres-driver.
Yes sure I checked and found something that perhaps helps:
They seem to be added to the _fluent_enums table:
But on the pg_catalog/pg_enum table only the multipleChoice is added
Perhaps it needs another one of the SQLAlterEnum
commands because it looks like in the debug log only the multipleChoice is done
2022-02-22T10:57:38+0100 debug codes.vapor.application : database-id=psql SQLAlterEnum(name: SQLKit.SQLIdentifier(string: "task_type"), value: Optional(SQLKit.SQLLiteral.string("multipleChoice")))
from fluent-postgres-driver.
Ah good spot - yep that's where the bug is. Thanks for reporting, we'll add this to the list to be fixed
from fluent-postgres-driver.
Related Issues (20)
- Accept URL string in configuration HOT 3
- Saving optional enum (nil) triggers: [ WARNING ] bind $3 type (UNKNOWN 0) does not match expected parameter type (TEXT) HOT 5
- 2.0.0 GM
- Type date but expression is of type text (transformAssignedExpr) HOT 5
- Migrations are now creating int8 fields as char in the DB and then the value gets messed up when querying HOT 1
- Aggregate SUM function fails HOT 1
- Sort by multiple field keys fail
- Postgres error thrown when using advised UUID ID field HOT 1
- [Feature request] Support JSONB column type for nested arrays / PostgreSQL
- simpleQuery flattens columns names to lower case HOT 1
- [Documentation] - We need thorough documentation on README or Wiki HOT 3
- Missing '#include <stdlib.h>'; 'abort' must be declared before it is used HOT 3
- debug logging no longer shows the RAW SQL HOT 4
- let user specify Postgres schema in the connection parameters. HOT 2
- No DEFERRABLE Constraint option
- DatabaseConfigurationFactory build error in 2.7.0 HOT 4
- Select SQL query for the fluent-postgres-driver with bindings
- PSQLError: Opening new connection for pool failed HOT 3
- func logging(to logger: Logger) -> any Database - Not working
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 fluent-postgres-driver.