Skip to content

Instantly share code, notes, and snippets.

View yesthesoup's full-sized avatar

Lauren Campbell yesthesoup

  • Wealthsimple
  • Montreal
View GitHub Profile
@yesthesoup
yesthesoup / test_migrations.py
Created September 24, 2020 21:57
Unit testing Flask and Alembic database migrations with pytest
from alembic.config import Config
from alembic.script import ScriptDirectory
from flask_migrate import downgrade, upgrade, stamp
from flask_project import create_app
from flask_project.config import TestingConfig
from flask_project.database import db # db = flask_sqlalchemy.SQLAlchemy()
# in conftest.py
@pytest.fixture
@yesthesoup
yesthesoup / multi_schema_dumper.rb
Last active April 8, 2024 20:14 — forked from drnic/schema_dumper.rb
Multi-schema Rails support via monkeypatching ActiveRecord's PostgreSQL::SchemaDumper
##
# Originally forked from https://gist.github.com/drnic/9d6e63802f1a7517434c25bb80f2ec09
# Works with Rails 7.0.8 and 7.1.2
# Intended to support a multi-schema, single DB Rails app, with separate files for the public schema (schema.rb)
# and the new schema (second_schema.rb)
# my starting point was an existing database for the Rails app,
# and then adding this new schema, new schema file, and new migrations directory.
# INTEGRATION STEPS: