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: add filename to deployments db #345

Merged
merged 6 commits into from
Nov 22, 2024

Conversation

PatrickAlphaC
Copy link
Contributor

@PatrickAlphaC PatrickAlphaC commented Nov 22, 2024

What I did

add a filename column to the database

How I did it

class DeploymentsDB:
    def __init__(self, path=":memory:"):
        if path != ":memory:":  # sqlite magic path
            path = Path(path)
            path.parent.mkdir(parents=True, exist_ok=True)

        # once 3.12 is min version, use autocommit=True
        self.db = sqlite3.connect(path)
        self.db.execute(_CREATE_CMD)

        # Migration for legacy DB without filename column
        if not self._filename_is_in_db():
            try:
                self.db.execute("ALTER TABLE deployments ADD COLUMN filename text;")
                self.db.commit()
            except sqlite3.Error as e:
                self.db.rollback()
                raise Exception(f"Failed to add 'filename' column: {e}")

How to verify it

You can run the test I created:

pytest -k test_deployments_db_migration

Description for the changelog

  • feat: Added migration for databases without the filename column

Cute Animal Picture

image

@PatrickAlphaC PatrickAlphaC changed the title feat: added db migration for non-ABI databases feat: added db migration for databases without the filename column Nov 22, 2024
@charles-cooper charles-cooper changed the title feat: added db migration for databases without the filename column feat: add filename to deployments db Nov 22, 2024
@charles-cooper charles-cooper merged commit a1cddb3 into vyperlang:master Nov 22, 2024
8 of 9 checks passed
@PatrickAlphaC PatrickAlphaC deleted the fix/db-migration branch November 22, 2024 21:55
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