GithubHelp home page GithubHelp logo

Comments (5)

mqus avatar mqus commented on June 22, 2024 1

I'm currently triaging all the old issues.

Is this bug about:

  1. We keep the old version even if we shouldn't or
  2. 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.

vitusortner avatar vitusortner commented on June 22, 2024

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.

mqus avatar mqus commented on June 22, 2024

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.

mqus avatar mqus commented on June 22, 2024

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.

vitusortner avatar vitusortner commented on June 22, 2024

Sounds reasonable 👍

from floor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.