Skip to content

Conversation

@zachdaniel
Copy link
Contributor

@zachdaniel zachdaniel commented Sep 7, 2020

Contributor checklist

  • My commit messages follow the Conventional Commit Message Format
    For example: fix: Multiply by appropriate coefficient, or
    feat(Calculator): Correctly preserve history
    Any explanation or long form information in your commit message should be
    in a separate paragraph, separated by a blank line from the primary message
  • Bug fixes include regression tests
  • Features include unit/acceptance tests

The tests I currently have are out of date, so what is left is tests that confirm that the proper migrations are generated, as well as documentation on the various features of the migrator.

Most notably:

  • prompts for determining if columns are being renamed
  • automatic foreign key determination
  • multiple resources backed by the same table
    • Errors on conflicting requirements for fields (e.g one resource saying name is a string, and the other saying it is an integer)
    • Disambiguation of primary keys, prompting for which to use as the actual primary key, and creates unique constraints for the others
    • Only setting default values if the default value is the same for all resources
    • only setting null: false if all resources meet that requirement

The usage:

mix ash_postgres.generate_migrations
# Read the generated migrations/hand-edit them to deal with any data-migrations or things the generator couldn't know about
mix ecto.migrate

Features not included in this:

  • configuration to make the migrator use anything different from the resource. For example, setting the default value for a column that isn't in the current specified list (which is just datetime/uuid functions)
  • configuration to source resource attributes from select statements
  • Eventually, when a "base_filter" can be configured, we will need to include that in unique constraints

@zachdaniel zachdaniel marked this pull request as draft September 7, 2020 08:09
@zachdaniel zachdaniel marked this pull request as ready for review September 11, 2020 00:19
@zachdaniel zachdaniel changed the title Migrator feat: snapshot-based migration generator Sep 11, 2020
@zachdaniel zachdaniel merged commit 24b743d into master Sep 11, 2020
@zachdaniel zachdaniel deleted the migrator branch September 11, 2020 00:26
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.

2 participants