-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
reverting doesn't seem to work #29
Comments
I'm away for a few days so won't be able to look into this. But all revert does is call into the FluentKit revert function. I assume you have added the database to Fluent.databases before calling revert. |
Did you add all the migrations to the migrator first? eg await fluent.migrations.add(CreatePlanet())
try await fluent.revert() |
Yes, the database and migrations have been added before I attempt the call to On a side note, I also checked the |
Is the |
Also can you post the code where you set up fluent and your migrations |
I deleted my database and re-applied the migration I've been testing with and yes, after running the migrations the new table is created and the Apply Migration Command: minisoc.fluent.databases.use(.sqlite(.file("test.db")), as: .sqlite)
await minisoc.fluent.migrations.add(CreateAccountsTable20241106140124())
try await minisoc.fluent.migrate() Revert command: minisoc.fluent.databases.use(.sqlite(.file("test.db")), as: .sqlite)
await minisoc.fluent.migrations.add(CreateAccountsTable20241106140124())
try await minisoc.fluent.revert()
The migration is defined as follows: import FluentKit
struct CreateAccountsTable20241106140124: AsyncMigration {
func prepare(on database: Database) async throws {
try await database.schema(Account.schema)
.id()
.field("username", .string)
.field("email", .string)
.field("password", .string)
.create()
}
func revert(on database: Database) async throws {
try await database.schema(Account.schema)
.delete()
}
} |
When using the todos-fluent example in hummingbird-examples I can see in the log the migrations being migrated and reverted as expected and those changes actually being applied to the database. What are you using to view the database? |
I've tried both the
Fluent.revert
andFluentMigrations.revertLast
functions and neither seem to be working on my SQLite3 database.no errors are thrown, and the single migration (a table creation) does not get reverted.
i've been testing this by running migrations then immediately trying to revert them, through separate invocations (I run my program with a migrate flag, then once it ends I run it with a revert flag)
i'm using Swift 6.0.1, with hummingbird-fluent version 2.0.0-beta.5
The text was updated successfully, but these errors were encountered: