Skip to content
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

Move Spree::Address#name attribute to the db #3908

Merged

Conversation

filippoliverani
Copy link
Contributor

@filippoliverani filippoliverani commented Jan 22, 2021

Description
Ref #3234

This PR pushes forward the migration to Spree::Address#name to replace firstname and lastname attributes. It adds a correseponding name column to the DB and replaces all the remaining direct attribute accesses to firstname and lastname with name.

The DB migration contains a blocking warning to force users to evaluate the impact of the upgrade and to choose the correct strategy to handle it in their store. In a future PR we will provide a complementary rake task to migrage existing data from firstname and lastname columns to the new name columns. New stores won't receive any warning and will be able to start working with the name field from scratch.

☝️ This piece will be moved into a separate rake task.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • [ ] I have updated Guides and README accordingly to this change (if needed)
  • [ ] I have added tests to cover this change (if needed)
  • [ ] I have attached screenshots to this PR for visual changes (if needed)

@filippoliverani filippoliverani force-pushed the filippoliverani/migrate-to-address-name branch from 1d72ede to aaf6b9c Compare January 22, 2021 16:46
@kennyadsl kennyadsl force-pushed the filippoliverani/migrate-to-address-name branch 3 times, most recently from c1caebe to b246e59 Compare January 25, 2021 10:02
@kennyadsl kennyadsl force-pushed the filippoliverani/migrate-to-address-name branch 3 times, most recently from 3782935 to b50c24d Compare January 26, 2021 13:36
@kennyadsl kennyadsl marked this pull request as ready for review January 26, 2021 13:59
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just introduce the name column first?

filippoliverani and others added 3 commits January 27, 2021 17:24
This will avoid having automatic getters and setters for these fields
and also be present in the list of attributes when the Address is
converted into other formats, for example, .as_json
@kennyadsl kennyadsl force-pushed the filippoliverani/migrate-to-address-name branch from b50c24d to a494722 Compare January 27, 2021 16:24
Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filippoliverani @kennyadsl thanks 👍 🎉

Copy link
Member

@jarednorman jarednorman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks good to me.

@kennyadsl kennyadsl merged commit 35898db into solidusio:master Jan 28, 2021
@kennyadsl kennyadsl deleted the filippoliverani/migrate-to-address-name branch January 28, 2021 10:16
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Feb 15, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running rake solidus:migrations:migrate_address_names:up will take
care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Feb 16, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running rake solidus:migrations:migrate_address_names:up will take
care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Feb 26, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running rake solidus:migrations:migrate_address_names:up will take
care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Feb 26, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running `rails solidus:migrations:migrate_address_names:up` will
take care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.

Running this task is required when upgrading to Solidus 3.0.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Mar 5, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running `rails solidus:migrations:migrate_address_names:up` will
take care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.

Running this task is required when upgrading to Solidus 3.0.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Mar 5, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running `rails solidus:migrations:migrate_address_names:up` will
take care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.

Running this task is required when upgrading to Solidus 3.0.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Mar 5, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running `rails solidus:migrations:migrate_address_names:up` will
take care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.

Running this task is required when upgrading to Solidus 3.0.
spaghetticode pushed a commit to nebulab/solidus that referenced this pull request Mar 8, 2021
After solidusio#3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running `rails solidus:migrations:migrate_address_names:up` will
take care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.

Running this task is required when upgrading to Solidus 3.0.
kennyadsl pushed a commit that referenced this pull request Mar 9, 2021
After #3908 the table spree_addresses includes the name
field, so it can be populated with historical data already present
in the table by joining the content of firstname and lastname.
Running `rails solidus:migrations:migrate_address_names:up` will
take care of the job.

The task is arranged in steps that require user input in order to
proceed:

  * the task will exit no-op when no record with blank name is
    found;
  * if records are found, the user is asked to confirm before
    proceeding;
  * the user is now asked for the record batch size to be used.
    My tests showed that 100'000 records per batch should balance
    the necessity to avoid locking records for long and have the
    script complete without too much overhead;
  * before migrating data, the user is asked to confirm once again.

Running this task is required when upgrading to Solidus 3.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants