Skip to content
Snippets Groups Projects

use flask-sqlalchemy for the main db

Merged Remco Tukker requested to merge feature/COMP-170_part_2_introduce_flask_sqlalchemy into develop
1 unresolved thread
  • added the Flask-SqlAlchemy and Flask-Migrate dependencies to replace session and migration boilerplate code
  • Updated all the orm queries to the new SqlAlchemy 2 API
Edited by Remco Tukker

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Remco Tukker added 12 commits

    added 12 commits

    • 6e62575f...b7fe7e0f - 11 commits from branch develop
    • 538048a9 - Merge branch 'develop' into feature/COMP-170_part_2_introduce_flask_sqlalchemy

    Compare with previous version

  • Remco Tukker added 1 commit

    added 1 commit

    • 14411075 - use flask-migrate for the migrations

    Compare with previous version

  • Remco Tukker added 1 commit

    added 1 commit

    • 6b736da7 - use sqlalchemy2 syntax everywhere

    Compare with previous version

  • Remco Tukker added 1 commit

    added 1 commit

    • 0f775788 - also use flask-sqlalchemy for the survey db

    Compare with previous version

  • Remco Tukker marked this merge request as ready

    marked this merge request as ready

  • Remco Tukker changed the description

    changed the description

    • When I run flask db migrate it detects that the enum name for charging structure feetype is different because of the naming changes:

      
      def upgrade():
          # ### commands auto generated by Alembic - please adjust! ###
          with op.batch_alter_table('charging_structure', schema=None) as batch_op:
              batch_op.alter_column('fee_type',
                     existing_type=postgresql.ENUM('flat_fee', 'usage_based_fee', 'combination', 'no_charge', 'other', name='fee_type'),
                     type_=sa.Enum('flat_fee', 'usage_based_fee', 'combination', 'no_charge', 'other', name='feetype'),
                     existing_nullable=True)
      
          # ### end Alembic commands ###
      
      
      def downgrade():
          # ### commands auto generated by Alembic - please adjust! ###
          with op.batch_alter_table('charging_structure', schema=None) as batch_op:
              batch_op.alter_column('fee_type',
                     existing_type=sa.Enum('flat_fee', 'usage_based_fee', 'combination', 'no_charge', 'other', name='feetype'),
                     type_=postgresql.ENUM('flat_fee', 'usage_based_fee', 'combination', 'no_charge', 'other', name='fee_type'),
                     existing_nullable=True)
      
          # ### end Alembic commands ###

      ..either we should keep the old name, or reapply migrations to fix the enum in postgres - you can make a decision and I will follow :smile:

      Other than this, the changes look good to me and can be merged

      Edited by Bjarke Madsen
    • Yes; this is just the enum in the db metadata though and it doesnt have any functional effect, so I was thinking to just include this migration in the next useful one as to not have an unnecessary migration. The reason its detected now is that in Flask-SqlAlchemy the compare-type setting defaults to true while in bare SqlAlchemy it defaults to false. The alternative would be to rename the python enum from FeeType to Fee_Type but I dont want to do that.

    • Please register or sign in to reply
  • Remco Tukker mentioned in commit 41de7f69

    mentioned in commit 41de7f69

  • merged

Please register or sign in to reply
Loading