-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plug Batch info on Kitt callback and move back City on User to simplify validation logic. #325
Changes from all commits
c5f09b0
4850c9a
0a6f168
7e56926
52b3889
2b55247
f7205a4
837b0bc
07e6384
828396b
194c053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddBackCityOnUsers < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
|
||
def change | ||
add_reference :users, :city, index: { algorithm: :concurrently } | ||
add_foreign_key :users, :cities, validate: false | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddForeignKeyForUsersCityRelationship < ActiveRecord::Migration[7.1] | ||
def change | ||
validate_foreign_key :users, :cities | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoveCityAndSizeFromBatches < ActiveRecord::Migration[7.1] | ||
def change | ||
safety_assured { remove_column :batches, :city_id, :bigint } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non on en a besoin. C'est elle qui force l'User à s'aligner sur son batch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Y a pas de choix, donc y a pas besoin de forcer. Un user a pas de batch ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je pense qu'il y a eu quiproquo: quand je dis "C'est elle qui force l'User à s'aligner sur son batch." ce que je veux dire c'est que c'est elle qui force l'User à s'aligner sur son batch dans notre modèle de donnée. Ça rend explicite une relation qui est seulement implicite ici. "Y'a pas de choix donc pas besoin de forcer" c'est pas un bon argument. On est dans la couche de cohérence des données là, la présence ou absence de choix est dans la couche applicative. C'est pas la mort de l'avoir enlevée, mais je trouve ça dommage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On pourra peut-être rétablir 🫣 |
||
safety_assured { remove_column :batches, :size, :int } | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Est-ce que ça veut dire qu'on crée un batch
0
quoi qu'il arrive ? C'est mieux un batch0
ou un batchnil
? cc @AquajEdit : à choisir,
nil
ça évite d'afficher un vieux0
tout moche dans le frontThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sauf que
nil.to_i == 0
, il faudrait échapper avec.&
non ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La validation du Batch ne permet pas de creer un batch avec un
number
0Donc nil.to_i ne respectera pas la validation et le batch ne sera pas persisté du coup le batch sera nil