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

[16.0][IMP] edi_storage_oca: Add script to migrate to v16 #95

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

QuocDuong1306
Copy link

Context:

  • Assume that storage_backend will still be installed in the old db and that we simply have to create the matching fs.storage records w/ their conf leaving the old storage.backend records untouched.

Notes:

  • Put this script to 16.0.1.0.0 because of changing storage_backend to fs_storage, if we put it to the later versions, the storages in backends have been changed, so can't link to the mapping records in fs.storage

  • storage_backend_ftp and storage_backend_s3 have not been migrated to 16.0 (and should not)

  • storage_backend depends on server_environment

    • we just need to create a fs_storage, and link it with the edi_backend
    • the rest (host/port/credentials) will come from the environment

    cc @simahawk @etobella

@etobella
Copy link
Member

etobella commented Jul 8, 2024

@luisDIXMIT

@QuocDuong1306 QuocDuong1306 force-pushed the 16.0-imp-edi_storage_oca-script branch from 967b6c1 to 8977c4f Compare July 9, 2024 04:16
@simahawk
Copy link
Contributor

simahawk commented Jul 10, 2024

@etobella would you be able to test this in real life?

@simahawk
Copy link
Contributor

  • storage_backend_ftp and storage_backend_s3 have not been migrated to 16.0 (and should not)

FTR I doubt we should not 😉

@etobella
Copy link
Member

  • the rest (host/port/credentials) will come from the environment

That is not true. We could define information directly on the storage. this information needs to be ported too

return

required_modules = ("storage_backend", "edi_storage_oca")
if not env["ir.module.module"].search(
Copy link
Member

Choose a reason for hiding this comment

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

I think you don't need this verificatiion. If you are in this script, you come from 15, so storage_backend is installed


def _create_fs_storage_records(env):
# Create a fs.storage record for each backend.storage
storage_backend_records = env["storage.backend"].search([])
Copy link
Member

Choose a reason for hiding this comment

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

I think we should only transform the backends that come from edi.backends. Probably we need to add some SQL here, but it is the cleaner option IMO

[("name", "in", required_modules), ("state", "=", "installed")]
):
return
if not openupgrade.column_exists(env.cr, "edi_backend", "new_storage_id"):
Copy link
Member

Choose a reason for hiding this comment

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

In order to avoid the create new column, change column to old and new to current you can do:

        _column_renames = {
            "edi_backend": [
                ("storage_id", False),            ],
        }
        openupgrade.rename_columns(env.cr, _column_renames)
        create_column(env.cr, "edi_backend", "storage_id", "int4")

The old field will have the following name: openupgrade.get_legacy_name("storage_id")

@nilshamerlinck
Copy link
Contributor

Hi @simahawk precision about that point:

storage_backend_ftp and storage_backend_s3 have not been migrated to 16.0 (and should not)

FTR I doubt we should not

of course some people might decide to migrate them, like storage_backend_sftp was
but what we meant here is that fs_storage is now the preferred way
and as concretely these modules are not available in 16.0, we needed a small trick to allow the migration script to manipulate storage.backend of various types, see here:

image

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.

None yet

4 participants