Comments (1)
I've had problems with this in the past because, in reality, people run database migrations in different orders.
Let's say we have three developers working at the same time
Consider this timeline:
Monday
- Developer 1 creates and their a database migration in their branch. It adds column
sometable.foo
in migration 0001 to their local db. - Developer 2 creates and runs a database migration in their branch. It adds column
sometable.bar
in migration 0002 to their local db.
Tuesday
- Developer 1 merges their code to production. Production table consists of [:id, :foo]
- Developer 2 rebases.
- Developer 2 runs
db:migrate
. Columnfoo
gets added to their database table. Their table consists of [:id, :bar, :foo] - Developer 2 submits a diff that changes the annotate order to db
Every time Developer 2 runs db:migrate
and annotate runs, it'll show a 'diff' on developer 2, since their local table is out of order. The only way out of this is to db rollback, and then roll forwards, or reset their db entirely.
Why do this at all?
I'm not convinced there's a lot of value to trying to manage the order of columns in the database. Unless you have an exceptional situation, you're micro-optimising for very little benefit.
- You can't later insert a column between columns 1 and 2 without rebuilding the whole table. Which involves massive downtime for most db engines
- Most ID fields should be indexed, so the placement in the table doesn't matter very much anyway.
from annotate_models.
Related Issues (20)
- Next release? HOT 2
- Active Admin not working when running migrations
- Is there any way to ignore attributes?
- Running annotate after changing sorting doesn't reorder the columns in the new comment
- Additional index annotation to other table with same name but with prefix HOT 1
- Unable to annotate: ActiveRecord::Encryption::Errors::Decryption HOT 4
- Annotate gem does not support Rails autoloader collapsed directories HOT 4
- Please add a ruby version constraint to gemfile
- How should I set up a CI job to ensure that annotations are up to date? HOT 3
- Column wrongly mistaken as a geometric point
- Fix code scanning alert - Polynomial regular expression used on uncontrolled data
- Rails 7, annotate --routes failed HOT 6
- Can't execute `annotate` or `bundle exec annotate` commands HOT 2
- Unable to annotate a single model HOT 1
- Make `with_comment_column` work with `Annotate.set_defaults` HOT 7
- Configuration for custom spec directory
- Does not find factories with default suffix example
- annotate_models doesn't auto-annotate on down / rollback migrations in multi-DB environments
- Throws error when using composite primary keys (supported natively by rails 7.1) HOT 1
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 annotate_models.