Skip to content

Instantly share code, notes, and snippets.

@aronbudinszky
Last active September 1, 2022 20:56
Show Gist options
  • Save aronbudinszky/8dcce4fae605dd2699c0d4c1642f6793 to your computer and use it in GitHub Desktop.
Save aronbudinszky/8dcce4fae605dd2699c0d4c1642f6793 to your computer and use it in GitHub Desktop.
import Fluent
import SQLKit
struct CreateVersionsCreatedAtIndex: AsyncMigration {
func prepare(on database: Database) async throws {
try await (database as! SQLDatabase)
.create(index: "versions_created_at_index") // Index name
.on("versions") // Table name
.column("created_at")
// You can also add more columns here if you want a multi-column index...
.run()
}
func revert(on database: Database) async throws {
try await (database as! SQLDatabase)
.drop(index: "versions_created_at_index")
.run()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment