x9c4
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Pulp3 Squashing Migrations ## Problem: * We have a lot of migrations. * Old migrations show paths where we have gone wrong and turned around. * There are migrations to create tables that are removed by later migrations. * There are migrations to rename fields on models. * There are migrations that change the types of fields. * Plugin migrations depend on pulpcore migrations. * Running all migrations in a new installation consumes a great amount of time. * We have supporting code (historical model) only needed to run ancient migrations. ## General Advice on Writing Migrations * Do not seed data in migrations; use a `post_migrate` signal handler instead. * Write data migrations only to update existing data and mark them `elidable=True`. * `pulpcore-manager squashmigrations` will skip them because there is no data to expect anyway. ## Squashing Migrations in Django see [Django docs](https://docs.djangoproject.com/en/3.2/topics/migrations/#migration-squashing) Squashing is meant to be a two step process in django: 1. Squash the migrations up to a specific one. * It will claim to replace the original migrations and if none of those was applied, it will be used to migrate the database in one step. * Ideally Django will optimize all the migrations to `CreateModel` and some extra steps for foreign keys and indices. 2. Delete the replaced migrations once you can be sure that all installations seeing the code either have applied all or none of them. * This will remove any trace of the previous migrations. * While we maybe able to do this in plugins, maybe we can never do this in pulpcore, once all plugins depend only on the squashed migration. (Can we enforce this with the deprecation policy?) Step one should be safe for Pulp at any time in core and in plugins. Step two is problematic. You cannot repeat step one without step two: `CommandError: You cannot squash squashed migrations! Please transition it to a normal migration first: https://docs.djangoproject.com/en/3.2/topics/migrations/#squashing-migrations` Should we start by squashing all migrations for a release? Probably not. ## General Advice on Squashing Migrations * After squashing, check that the schema produced is reflecting your models. * There have been cases with incorrect `default` values. https://code.djangoproject.com/ticket/26223 * Observe the produced result. The optimization algorithm is not perfect. * Hand optimizing may be possible. * If you change the number of the squashed migration from `0001_...` to one more than the last existing migration, django will continue to count from there for future migrations. * Not sure this is a good idea. * The squashed migration may declare multiple dependencies on migrations in pulpcore. * It should be safe to only keep the latest. * Check the dependencies and wen deleting squashed migrations, adjust the dependencies of later migrations. * Never, ever, ever rename an existing migration. * Squashing a squashed migration again may optimize it even more. * The optimize command should help here. * Keep at least one migration unsquashed to allow for easier dependency specifications. ## Squashing Migrations in Pulp Plugin migrations depend on pulpcore migrations. But migrations may only be deleted once there are no more dependencies. In general a plugin must be installable after all pulpcore migrations have run. **Note:** With deleting migrations we loose the possibility to upgrade from everywhere. Squashing the migration in plugins no other plugins depend on should be much simpler. Plan: - Introduce empty migrations for breaking change releases to make the whole process more transparent. - Plugins should adjust their dependencies on these or later migrations. - Squash pulpcore migrations in a breaking change release. - Require all plugins to release compatible with squashed migration. - Delete redundant migrations with next breaking change release. ``` pulpcore 3.25 0001_initial ... 0020 0001_squashed_0020 # "squashed migration" 0021_release_3.25 # plugin depend on this once they declare pulpcore>=3.25,<3.30 pulpcore 3.30 0001_squashed_0020 # rewritten to be a "normal migration" (ie loses 'replace' stmts) 0021_release_3.25 # plugins can still depend on this (will be removed in 3.35) 0022 ... 0030 0001_squashed_0030 # "squashed migration" 0031_release_3.30 # plugin depend on this once they declare pulpcore>=3.30,<3.35 pulpcore 3.35 0001_squashed_0030 # rewritten to be a "normal migration" 0031_release_3.30 # plugins can still depend on this (will be removed in 3.40) 0032 ... 0040 0001_squashed_0040 # "squashed migration" 0041_release_3.35 # plugin depend on this once they declare pulpcore>=3.35,<3.40 ``` There is an experiment to manipulate migrations as needed for this process: https://github.com/mdellweg/pulpcore/tree/migration_tools Django 4.1 ships its own optimizemigration command. ## 8.22.2022 - Notes ## Attendees: x9c4, ipanova, ggainey, dralley, humerto, fao89, bmbouter * implications on old-installs: if you're too old, you may have to do multi-step updates * e.g.: to go from 3.24 to 3.36, you would need to upgrade to 3.25, then 3.30, then to 3.36 * ipanova: this has a large potential impact on our product-users * bmbouters: even if squashing is painless, the multi-step-upgrade problem may make this a nonstarter * dalley: not seeing a blocker to squashing **plugin** migrations, independent from whatever we do with pulpcore * mdellweg: deleting migrations has the same impact on plugins as pulpcore, in terms of upgrade impact * ipanova: need to think about this harder, esp the upgrade-path issue * mdellweg: if we don't delete migrations, avoid the multi-step-upgrade problem, but can only ever squash **once** * ggainey/ipanova: current number of migrations is partially a result of the period we're coming out of (LOTS of migrations early in pulp3, rate-of-change WAY lower now) ## Action Item * [mdellweg] open discussion on Discourse, point to this doc * larger audience than pulpcore

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully