Skip to content

Commit

Permalink
SIM-DB-Decouple startup script in order to use plain postgres DB (#410)
Browse files Browse the repository at this point in the history
* chore: use postgresql public image and add necessary alembic migration

Signed-off-by: Agustín Ramiro Díaz <[email protected]>

* fix: wrong action trigger

Signed-off-by: Agustín Ramiro Díaz <[email protected]>

* fix: trailing whitespace

Signed-off-by: Agustín Ramiro Díaz <[email protected]>

* fix: remove custom network

Signed-off-by: Agustín Ramiro Díaz <[email protected]>

* fix: remove feedbuzz network

Signed-off-by: Agustín Ramiro Díaz <[email protected]>

---------

Signed-off-by: Agustín Ramiro Díaz <[email protected]>
  • Loading branch information
AgustinRamiroDiaz authored Aug 25, 2024
1 parent 9c481d9 commit 67cd3c4
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 79 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/docker-build-and-push-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ jobs:
secrets:
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

database:
uses: ./.github/workflows/docker-build-and-push-image.yml
with:
docker_build_context: .
dockerfile: docker/Dockerfile.database
dockerhub_repo: yeagerai/simulator-database
dockerhub_username: ${{ vars.DOCKERHUB_USERNAME }}
secrets:
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

database-migration:
uses: ./.github/workflows/docker-build-and-push-image.yml
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/docker-build-and-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ on:
secrets:
dockerhub_token:
required: true
push:
tags:
- "v*.*.*"

permissions:
contents: read
Expand Down
53 changes: 0 additions & 53 deletions backend/database_handler/initialization/init-db.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# revision identifiers, used by Alembic.
revision: str = "188ca1c3a340"
down_revision: Union[str, None] = None
down_revision: Union[str, None] = "953de60a1dd8"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

Expand Down
88 changes: 88 additions & 0 deletions backend/database_handler/migration/versions/953de60a1dd8_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""init
Revision ID: 953de60a1dd8
Revises:
Create Date: 2024-08-21 09:34:07.525299
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "953de60a1dd8"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"current_state",
sa.Column("id", sa.String(length=255), nullable=False),
sa.Column("data", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=True,
),
sa.PrimaryKeyConstraint("id", name="current_state_pkey"),
)
op.create_table(
"transactions",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("from_address", sa.String(length=255), nullable=True),
sa.Column("to_address", sa.String(length=255), nullable=True),
sa.Column("input_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column("data", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.Column(
"consensus_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True
),
sa.Column("nonce", sa.Integer(), nullable=True),
sa.Column("value", sa.Numeric(), nullable=True),
sa.Column("type", sa.Integer(), nullable=True),
sa.Column("gaslimit", sa.BigInteger(), nullable=True),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=True,
),
sa.Column("r", sa.Integer(), nullable=True),
sa.Column("s", sa.Integer(), nullable=True),
sa.Column("v", sa.Integer(), nullable=True),
sa.CheckConstraint(
"type = ANY (ARRAY[0, 1, 2])", name="transactions_type_check"
),
sa.PrimaryKeyConstraint("id", name="transactions_pkey"),
)
op.create_table(
"validators",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("stake", sa.Numeric(), nullable=False),
sa.Column("config", postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column("address", sa.String(length=255), nullable=True),
sa.Column("provider", sa.String(length=255), nullable=True),
sa.Column("model", sa.String(length=255), nullable=True),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=True,
),
sa.PrimaryKeyConstraint("id", name="validators_pkey"),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("validators")
op.drop_table("transactions")
op.drop_table("current_state")
# ### end Alembic commands ###
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ services:
restart: always

postgres:
build:
context: ./
dockerfile: ./docker/Dockerfile.database
image: postgres:12.19-alpine
ports:
- "${DBPORT}:5432"
environment:
Expand Down
9 changes: 0 additions & 9 deletions docker/Dockerfile.database

This file was deleted.

0 comments on commit 67cd3c4

Please sign in to comment.