-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from planetarium/release/0.8.0
Release/0.8.0
- Loading branch information
Showing
28 changed files
with
909 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
common/alembic/versions/2822c456abc3_add_unique_constraint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Add unique constraint | ||
Revision ID: 2822c456abc3 | ||
Revises: 5bf8ab4f3b13 | ||
Create Date: 2023-12-05 01:11:38.405536 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '2822c456abc3' | ||
down_revision = '5bf8ab4f3b13' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_unique_constraint("voucher_request_receipt_id_unique", 'voucher_request', ['receipt_id']) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint("voucher_request_receipt_id_unique", 'voucher_request', type_='unique') | ||
# ### end Alembic commands ### |
46 changes: 46 additions & 0 deletions
46
common/alembic/versions/5bf8ab4f3b13_add_voucher_request_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Add voucher_request table | ||
Revision ID: 5bf8ab4f3b13 | ||
Revises: 57e65ed34bd6 | ||
Create Date: 2023-12-01 11:22:16.116276 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5bf8ab4f3b13' | ||
down_revision = '57e65ed34bd6' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('voucher_request', | ||
sa.Column('receipt_id', sa.Integer(), nullable=False), | ||
sa.Column('uuid', sa.UUID(), nullable=False), | ||
sa.Column('agent_addr', sa.Text(), nullable=False), | ||
sa.Column('avatar_addr', sa.Text(), nullable=False), | ||
sa.Column('planet_id', sa.LargeBinary(length=12), nullable=False), | ||
sa.Column('product_id', sa.Integer(), nullable=False), | ||
sa.Column('product_name', sa.Text(), nullable=False), | ||
sa.Column('status', sa.Integer(), nullable=True), | ||
sa.Column('message', sa.Text(), nullable=True), | ||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), | ||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=True), | ||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True), | ||
sa.ForeignKeyConstraint(['product_id'], ['product.id'], ), | ||
sa.ForeignKeyConstraint(['receipt_id'], ['receipt.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_index(op.f('ix_voucher_request_uuid'), 'voucher_request', ['uuid'], unique=False) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f('ix_voucher_request_uuid'), table_name='voucher_request') | ||
op.drop_table('voucher_request') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
"garage", | ||
"receipt", | ||
"product", | ||
"voucher", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import uuid | ||
|
||
from sqlalchemy import Column, Text, Integer, ForeignKey, UUID, LargeBinary | ||
from sqlalchemy.orm import relationship, backref, Mapped | ||
|
||
from common.models.base import Base, TimeStampMixin, AutoIdMixin | ||
from common.models.product import Product | ||
from common.models.receipt import Receipt | ||
from common.utils.receipt import PlanetID | ||
|
||
|
||
class VoucherRequest(AutoIdMixin, TimeStampMixin, Base): | ||
__tablename__ = "voucher_request" | ||
receipt_id = Column(Integer, ForeignKey("receipt.id"), nullable=False, unique=True) | ||
receipt: Mapped["Receipt"] = relationship("Receipt", foreign_keys=[receipt_id], uselist=False, | ||
backref=backref("voucher_request")) | ||
|
||
# Copy all required data to view all info solely with this table | ||
uuid = Column(UUID(as_uuid=True), nullable=False, index=True, default=uuid.uuid4, | ||
doc="Internal uuid for management") | ||
agent_addr = Column(Text, nullable=False) | ||
avatar_addr = Column(Text, nullable=False) | ||
planet_id = Column(LargeBinary(length=12), nullable=False, default=PlanetID.ODIN.value, | ||
doc="An identifier of planets") | ||
product_id = Column(Integer, ForeignKey("product.id"), nullable=False) | ||
product: Mapped["Product"] = relationship("Product", foreign_keys=[product_id], uselist=False) | ||
product_name = Column(Text, nullable=False) | ||
|
||
# Voucher request result | ||
status = Column(Integer, nullable=True) | ||
message = Column(Text, nullable=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.