Comments (5)
I'm currently triaging all the old issues.
Is this bug about:
- We keep the old version even if we shouldn't or
- We will fail in a big way but should keep the old database instead?
The description is not quite clear about this 😉
If you mean 1., what should be done to fix this?
If you mean 2., then to be honest I don't see how this would work, as the migration simply updates the database to match with the compiled entities, DAOs and other integrations. Keeping the old database simply will throw errors when updating/querying entities and not solve any problem.
from floor.
Fair points. I was under the impression that when a migration e.g. from version 1 to 2 fails, version 2 will still be the new database version. This means that no data has been migrated but the new version is used already.
Solutions:
- provide the possibility of validating manual migrations earlier 👎
- make Floor generate migrations 🚀
If Floor would be able to generate migrations the chances would be smaller that these fail. What are your thoughts on this? @mqus
from floor.
I think generating migrations is pretty impossible to get right... But I haven't worked with many ORMs yet[1] to have a good impression on how others do this. Why do I think it is impossible then? The following has to happen in migrations:
- adding/removing/changing columns
- adding/removing tables with constraints (indices/relations to other tables)
All of the above are very semantic operations which heavily depend on the application logic. I also think that they cannot be described more concise than in sql.
I think that failing early and loud is the right way, although i'm currently not near a pc to look at the code and what would be possible.
[1]The one that immediately comes to my mind is diesel in rust, in which the migrations are the only sql you will have to write. The fully-migrated database is then type-validated with the annotated entities. But that's a completely different orm concept.
from floor.
After looking at the code it doesn't seem impossible to fail when we need to. I would also automatically put each migration into a Transaction
that gets rolled back if anything fails. This would need Migration.migrate
to accept a Transaction
instead of a Database
, which should be a painless substitution in many cases.
Regarding the integer value of the version field, I think this can be set manually and we should probably do this after each successful migration ourselves.
from floor.
Sounds reasonable 👍
from floor.
Related Issues (20)
- Improve FTS documentation and add some examples
- Not supported on Flutter Web HOT 1
- dependecy conflict with riverpod_lint 2.3.3 HOT 2
- Dumplicate field name when entity implement form abstract class HOT 1
- duplicate field name when entity implement form abstract class
- Unhandled Exception: type 'Null' is not a subtype of type 'double' in type cast HOT 1
- This exception cannot be executed on the entire floor library
- trying to get a SUM of a field with floor. HOT 1
- Custom Database File Path
- sqlite wal HOT 1
- How to update a List of an object as field of entity into table in Floor
- How add rawQuery added ?? HOT 2
- Are there any plans to adapt HarmonyOS HOT 4
- Imports collision HOT 1
- #802 still an issue. any help?
- Casting to double might not work; HOT 1
- dependencies issue HOT 5
- Invalid query (failing to parse) does not throw an error
- onCreate callback is not being called, "tbl not found" exception
- How to select with like ??? HOT 3
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 floor.