Skip to content

Commit

Permalink
Make parent not null, add commit index (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Apr 21, 2021
1 parent f44ffe1 commit 12573ba
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 79 deletions.
9 changes: 8 additions & 1 deletion conbench/entities/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Commit(Base, EntityMixin):
__tablename__ = "commit"
id = NotNull(s.String(50), primary_key=True, default=generate_uuid)
sha = NotNull(s.String(50))
parent = Nullable(s.String(50))
parent = NotNull(s.String(50))
repository = NotNull(s.String(100))
message = NotNull(s.String(250))
author_name = NotNull(s.String(100))
Expand All @@ -24,6 +24,13 @@ class Commit(Base, EntityMixin):
timestamp = NotNull(s.DateTime(timezone=False))


s.Index(
"commit_index",
Commit.sha,
unique=True,
)


class _Serializer(EntitySerializer):
def _dump(self, commit):
return {
Expand Down
78 changes: 0 additions & 78 deletions conbench/tests/migrations/test_662175f2e6c6_backfill_parent.py

This file was deleted.

23 changes: 23 additions & 0 deletions migrations/versions/b86538f84533_commit_sha_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""commit sha index
Revision ID: b86538f84533
Revises: bb5acca23f97
Create Date: 2021-04-21 13:35:38.613978
"""
from alembic import op


# revision identifiers, used by Alembic.
revision = "b86538f84533"
down_revision = "bb5acca23f97"
branch_labels = None
depends_on = None


def upgrade():
op.create_index("commit_index", "commit", ["sha"], unique=True)


def downgrade():
op.drop_index("commit_index", table_name="commit")
28 changes: 28 additions & 0 deletions migrations/versions/bb5acca23f97_parent_not_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""parent not null
Revision ID: bb5acca23f97
Revises: 662175f2e6c6
Create Date: 2021-04-21 11:11:00.621174
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "bb5acca23f97"
down_revision = "662175f2e6c6"
branch_labels = None
depends_on = None


def upgrade():
op.alter_column(
"commit", "parent", existing_type=sa.VARCHAR(length=50), nullable=False
)


def downgrade():
op.alter_column(
"commit", "parent", existing_type=sa.VARCHAR(length=50), nullable=True
)

0 comments on commit 12573ba

Please sign in to comment.