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

[ MB-11957 ] update migration docs #119

Merged
merged 7 commits into from
Mar 15, 2022

Conversation

NamibiaTorres
Copy link
Contributor

This PR is associated with JIRA ticket MB-11957

Review instruction:

  • look at the delete migrations sections and confirm that the instructions are correct.

@@ -158,6 +159,15 @@ Migrations are run by the `milmove migrate` command. This allows us to leverage

The reason to use a `make` target is because it will correctly set the migration flag variables and target the correct database with environment variables.

## Delete Migrations
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait so is this saying to delete the migration file itself, or only remove the line in the manifest that points to it?

Mostly because if it's the latter, then to me it's not so much about "deleting" a migration, as making edits and re-running a migration, in which case running the make db_dev_reset db_dev migrate command would handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delete the migration file itself. Although if there is a better way to delete a migration, I'd rather offer that option...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I failed to explain this well when we paired. You only need to remove the file from the manifest, you don't need to delete the migration file. If you do delete the file the build will complain of a missing migration since it would still be in the manifest.

I would also add a note that this is only if you want to undo a migration you've added locally. For the deployed environments the process is to create a new migration that un-does the change.

Let me know if this helps if not I'm happy to connect on Monday :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I meant. The migration file that is in the manifest, not the entire folder. Does that clear things up or is there another migration file that I didn't understand?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think maybe in that case this should be split into two sections. Like one for running a changed migration (that hasn't made it to a deployed env). Which I think would be two steps:

  1. Make changes to migration

  2. Run

    make db_dev_reset db_dev migrate

And a section on deleting a migration fully. This one could have two things, one about it being local only still, so 3 steps:

  1. Remove the line in the manifest pointing at the migration file.

  2. Delete the migration file

  3. Run

    make db_dev_reset db_dev migrate

And a part mentioning that if doing it for a migration that has already been run against the deployed environments, that we need to follow our zero-downtime migrations practice (which is on this page).

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever delete migrations once they have been deployed? Not sure that is something we need to document, at least until we actually need to do so.

@rogeruiz rogeruiz changed the title Mb 11957 update migration docs [ MB-11957 ] update migration docs Mar 14, 2022
Comment on lines 10 to 14
2. [Add the new SQL to the generated file](#writing-migrations)
3. [Set up your database](#Setup)
4. [Run the migrations](#Running-Migrations)
5. [Delete a migration](#Delete-Migrations)
6. Test your new migration
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that docusaurus automatically adds the right numbers when it renders the real page so these should all be 1. still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks!

Copy link
Contributor

@felipe-lee felipe-lee left a comment

Choose a reason for hiding this comment

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

LGTM, I made a minor suggestion, but it's not vital, so up to you whether it goes in or not.

@@ -158,6 +159,13 @@ Migrations are run by the `milmove migrate` command. This allows us to leverage

The reason to use a `make` target is because it will correctly set the migration flag variables and target the correct database with environment variables.

## Update Migrations Locally
In the event that you need to make an edit to a migration that you have just created prior to merging it into the main branch,
you can update the migration with your edits and rerun it using: `make db_dev_reset db_dev_migrate`
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor suggestion, this makes it so there's a "copy" button on the right so people can quickly copy the command. Kind of like the first command in the Creating Secure Migration section. Contrasted with the commands in the Running Migrations section. See how in the latter, they're formatted, but have to be highlighted to be copied, while in the former, there's a copy button on the right when you hover over the box.

Suggested change
you can update the migration with your edits and rerun it using: `make db_dev_reset db_dev_migrate`
you can update the migration with your edits and rerun it using:
```shell
make db_dev_reset db_dev_migrate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minor suggestion, this makes it so there's a "copy" button on the right so people can quickly copy the command. Kind of like the first command in the Creating Secure Migration section. Contrasted with the commands in the Running Migrations section. See how in the latter, they're formatted, but have to be highlighted to be copied, while in the former, there's a copy button on the right when you hover over the box.

Thanks @felipe-lee , do you happen to understand the difference between writing shell and writing console? I see we do both in this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the difference is tbh. I tried looking into it and Docusaurus has this section on supported languages:
https://docusaurus.io/docs/markdown-features/code-blocks#supported-languages

Based on that, it looks like the default supported languages are these:
https://github.com/FormidableLabs/prism-react-renderer/blob/master/src/vendor/prism/includeLangs.js

But neither shell nor console are on there...You can extend the default list, but looking at our docusaurus config, it looks like we haven't added more languages:

prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},

Digging into it some more, it looks like this is the full list of supported languages: https://prismjs.com/#supported-languages

That docs says shell is an alias for bash so I guess that's why that one works, but there's no mention of console

I tried looking into it some more, and ended up on a thread with people talking about the syntax highlighters github uses (or people think they use?). That pointed me to these two different highlighters:

So yeah, I'm not entirely sure. Based on the thread I linked above where people were talking about the gh syntax one, it seems console might be able to handle the terminal prompt, but I haven't really tested it. I personally lean toward shell since it seems to be a common default language that syntax highlighters support, but I could be wrong. Maybe others know more.

@NamibiaTorres NamibiaTorres merged commit 071f511 into main Mar 15, 2022
@NamibiaTorres NamibiaTorres deleted the MB-11957-Update-Migration_docs branch March 15, 2022 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants