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

feat: database migrations #33

Merged
merged 9 commits into from
Aug 10, 2022
Merged

feat: database migrations #33

merged 9 commits into from
Aug 10, 2022

Conversation

marcotas
Copy link
Contributor

@marcotas marcotas commented Aug 8, 2022

Available commands:

  • make:migration
  • migrate:status
  • migrate
  • migrate:rollback
  • migrate:fresh
  • db:wipe

- renamed 'version' to 'id' in migrations
- change from integer to timestamp string in the format
of 'yyyy_MM_dd_HHmmss'
@marcotas marcotas changed the title feat: full migrations feature feat: database migrations Aug 8, 2022
@marcotas marcotas requested a review from Wdestroier August 8, 2022 22:23
Copy link
Collaborator

@Wdestroier Wdestroier left a comment

Choose a reason for hiding this comment

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

More database features, great 😄!! I have written a few notes unrelated to schema/table migration.

- refactor(database): refactor database operations individually as
contracts to a single class implementing a contract for the database
driver. This makes new implementations for new drivers easier in
the future.
It wipes all database tables and re-run all migrations.
- refactor: all migration commands to "migrations" category
- chore: add more tests to migration commands to test command name,
description and category.
@marcotas marcotas marked this pull request as ready for review August 10, 2022 19:06
@marcotas marcotas requested a review from Wdestroier August 10, 2022 19:07
Future<int> dropAllTables();
Future<int> update(Query query, MappedRow row);
Future<List<MappedRow>> process(Query query);
String toSql(Query query);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Wdestroier I followed your suggestion about refactoring the database operations to put them all in a class that makes it easier to implement for other drivers and here you are. Now, we just need to implement two classes DatabaseOperator and SchemaProcessor to implement a new database driver. In the future, I will also refactor the SchemaProcessor to use the database operator instead. This will make it, even more, easier to implement in the future. Please let me know if you have any other thoughts or suggestions.

Now I just implemented the PostgresDatabaseOperator to follow the database operator contract (interface). The postgres directory contains everything related to the Postgres driver implementation. It's a good pattern but we don't necessarily need to follow it, but I think it's a good way to implement this contract.

@marcotas marcotas merged commit e3c506b into main Aug 10, 2022
@marcotas marcotas deleted the marco/feature/migrations branch August 10, 2022 23:04
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