Skip to content

Commit

Permalink
updated suggested chages
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachinbisht27 committed Apr 18, 2024
1 parent c48fa2b commit 5c47b4b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
17 changes: 17 additions & 0 deletions api/utils/db_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import traceback

from api import db
from api.utils.loggingutils import logger


def save(data):
try:
db.session.add(data)
db.session.commit()
except Exception as e:
logger.error(
"Error occurred while committing the data in the database."
f"Error message: {e}"
)
logger.debug(traceback.format_exc())
db.session.rollback()
36 changes: 36 additions & 0 deletions migrations/versions/70bea50174bf_initial_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Initial migration.
Revision ID: 70bea50174bf
Revises:
Create Date: 2024-04-18 17:18:19.882178
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "70bea50174bf"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"webhook_transaction_log",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("payload", sa.Text(), nullable=True),
sa.Column("processed", sa.Boolean(), nullable=False),
sa.Column("attempts", sa.Integer(), nullable=False),
sa.Column("created_on", sa.DateTime(), nullable=True),
sa.Column("updated_on", sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("webhook_transaction_log")
# ### end Alembic commands ###

0 comments on commit 5c47b4b

Please sign in to comment.