How would one migrate an enum using AsyncMigration? There are a few examples online of migrating one using the EventLoopFuture, but my preference is to use Swift Concurrency.
Migrating an Enum in Vapor using AsyncMigration
51 Views Asked by Sam Doggett At
1
There are 1 best solutions below
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in ENUMS
- How to solve unchecked cast
- Approaches to persist enum in java
- how to convert varchar variable to enum without first declaring the enum type?
- Why does Enum require to implement toEnum and fromEnum, if that's not enough for types larger than Int?
- Put enum in tuple and return tuple from C++ function
- Retrieving text value from ENUM by using int number that doesn't exist in said ENUM returns that int number in C#?
- match a partially moved enum Rust
- Separate big Enum list in different file in C#
- for loop is not printing all defined enum
- SwiftUI @Observable class ViewModel gets initialized twice when setting an enum variable, but not class ViewModel: ObservableObject
- Generate Custom Enum using NSWag cli
- Few enums have constants values in common, causing OpenAPI Generator to fail. How to put some of the model classes, types in different packages?
- Get int value from Enum in Visual Scripting (Unity)
- Blazor custom dropdown with HTML select and sorting by text, not value for enums
- How to use php8 enum types in Laravel where conditions?
Related Questions in FLUENT
- Include particle removal in the DPM concentration UDF
- How to auto select item from Fluent UI Dropdown
- Entity Framework Core 7 - configuring two keys
- How to use custom icon on coherence/fluent UI Navigation Bar With reactjs
- Does setting a .unique(on:) constraint affect the uniqueness of the .id in fluent/vapor?
- node module error when creating outlook web add-in
- fluent flyoutsubitem disappears
- Fluent interfaces with pipelining or method chaining in Python
- Vapor Fluent OR relationship
- Fluent way (builder style) of creating a Mockito mock with method stubs
- Black: formatting of fluent method calls
- Migrating an Enum in Vapor using AsyncMigration
- fluent-bit parse text as json
- Blazorise fluentvalidation in datagrid Net 8.0
- How to hide i icon when adding a tooltip? [typescript]
Related Questions in VAPOR
- Swift Timer doesn't work on Linux. Works on macOS
- Streaming multiple payloads through a response on swift Vapor 4
- Is it possible to create a WebServer on iOS which is written in C++
- Detect type of vapor worker at runtime
- Does setting a .unique(on:) constraint affect the uniqueness of the .id in fluent/vapor?
- Connect MySQL configuration with CA certificate?
- How to install swift core libraries in production ubuntu server?
- Vapor Fluent OR relationship
- How can I send an image and a JSON together from my Swift client side to my vapor server side?
- How to send multipart form data request with vapor client
- How to remove Duplicate items from siblings filter in Fluent Vapor 4?
- Passkeys and Apple Associated Domains
- Try to use SES Services with Soto SDK and Vapor 4 to send email with my own route
- Swift Vapor Console App - The operation couldn’t be completed. Permission denied
- Local development with the apple-app-site-association file
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
After doing a bit of debugging, I was able to get everything working using
AsyncMigration. I also find it a bit cleaner to read than using anEventLoopFuture.Suppose we want to add an
enumrepresenting user roles:You'd create a Fluent model and add the field:
Lastly, you'd want to migrate it in two steps:
I prefer to use the
rawValue, to ensure everything is Strongly bound.Also note I added
.custom("DEFAULT '\(User.Role.appUser.rawValue)'")to thefieldinitializer. This will default the database's column to be anapp_user(optional).