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

Migrate to PostgreSQL #54

Merged
merged 16 commits into from
Aug 8, 2024
Merged

Migrate to PostgreSQL #54

merged 16 commits into from
Aug 8, 2024

Conversation

AAGaming00
Copy link
Member

No description provided.

.github/workflows/checks.yaml Outdated Show resolved Hide resolved
@@ -4,7 +4,7 @@ services:
build: .
container_name: plugin_store
environment:
- DB_PATH=/app/.database/plugin_store_new.db
- DB_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want this DB_URL specified for local dev, as the postgres instance starts in the same dockerfile anyway.

@@ -4,26 +4,32 @@ services:
build: .
container_name: "${DEPLOYMENT_NAME}"
environment:
- DB_PATH
- DB_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, same here. We can build it from POSTGRES_PASSWORD to not have it hardcoded here.

def db_sessionmaker(db_engine):
return sessionmaker(bind=db_engine, autoflush=False, future=True, expire_on_commit=False, class_=AsyncSession)
@pytest.fixture(scope="session")
def seed_db_sessionmaker(seed_db_engine: tuple["AsyncEngine", "sessionmaker"]) -> "sessionmaker":
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have unseed DB anymore, we can drop seed from names everywhere.

AAGaming00 and others added 13 commits August 8, 2024 23:01
for data migration: .dump the sqlite, edit the .sql to remove everything but the BEGIN TRANSACTION, INSERTs, and COMMIT, then edit it to look like this

SET session_replication_role = 'replica'; -- Hack to make type checking more lenient, changed back later
update pg_cast set castcontext='a' where casttarget = 'boolean'::regtype; -- Hack to allow int to boolean conversion, changed back later
BEGIN TRANSACTION;
tons of inserts
COMMIT;
update pg_cast set castcontext='e' where casttarget = 'boolean'::regtype;
SET session_replication_role = 'origin';

then run migrations via the makefile on a new postgres db and then load the sql in
Tests were failing due to wrong default ordering of plugins being
checked by them.
Pytest freezegun is no longer maintained, switched to a fork. Also
bumped pytest-asyncio due to inability to use async fixtures in other
scopes than `function` in older version.
Fixed black, isort and mypy failing
Seeder (FakePluginGenerator) no longer uses logic from Database class
nor the time freezer for seeding the database.
Make use of DB transactions to rollback tests back to the original state
instead of recreating DB on each test.
@gbdlin gbdlin force-pushed the postgresql branch 2 times, most recently from 8265022 to 8b0423f Compare August 8, 2024 21:11
@AAGaming00
Copy link
Member Author

we should really merge this already

`pull_request` trigger needs some more work to be functional. Reverting
back to `pull_request_target` for now.
@gbdlin gbdlin merged commit 0d709fd into main Aug 8, 2024
7 checks passed
@gbdlin gbdlin deleted the postgresql branch August 8, 2024 21:41
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.

3 participants