kind of a mess lol but file caching and front end

This commit is contained in:
2025-04-17 13:28:49 -04:00
parent 21408af48c
commit 8f35cedb4a
45 changed files with 1435 additions and 1316 deletions

View File

@@ -5,14 +5,6 @@ from sqlalchemy import pool
from alembic import context
# Import your models here
from app.db.database import Base
from app.models.inventory import Inventory
from app.models.card import Card
from app.models.box import Box, OpenBox
from app.models.game import Game
from app.models.file import File
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
@@ -24,6 +16,10 @@ if config.config_file_name is not None:
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from app.db.database import Base
from app.models import *
target_metadata = Base.metadata
# other values from the config, defined by the needs of env.py,

View File

@@ -19,8 +19,10 @@ depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
"""Upgrade schema."""
${upgrades if upgrades else "pass"}
def downgrade() -> None:
"""Downgrade schema."""
${downgrades if downgrades else "pass"}

View File

@@ -1,49 +0,0 @@
"""create tcgplayer categories table
Revision ID: 2025_04_09_create_tcgplayer_categories_table
Revises: remove_product_id_unique_constraint
Create Date: 2025-04-09 23:20:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '2025_04_09_create_tcgplayer_categories_table'
down_revision: str = 'remove_product_id_unique_constraint'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table('tcgplayer_categories',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('category_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('display_name', sa.String(), nullable=True),
sa.Column('seo_category_name', sa.String(), nullable=True),
sa.Column('category_description', sa.String(), nullable=True),
sa.Column('category_page_title', sa.String(), nullable=True),
sa.Column('sealed_label', sa.String(), nullable=True),
sa.Column('non_sealed_label', sa.String(), nullable=True),
sa.Column('condition_guide_url', sa.String(), nullable=True),
sa.Column('is_scannable', sa.Boolean(), nullable=True, default=False),
sa.Column('popularity', sa.Integer(), nullable=True, default=0),
sa.Column('is_direct', sa.Boolean(), nullable=True, default=False),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('category_id')
)
op.create_index('ix_tcgplayer_categories_id', 'tcgplayer_categories', ['id'], unique=False)
op.create_index('ix_tcgplayer_categories_category_id', 'tcgplayer_categories', ['category_id'], unique=True)
def downgrade() -> None:
op.drop_index('ix_tcgplayer_categories_category_id', table_name='tcgplayer_categories')
op.drop_index('ix_tcgplayer_categories_id', table_name='tcgplayer_categories')
op.drop_table('tcgplayer_categories')

View File

@@ -1,95 +0,0 @@
"""create mtgjson tables
Revision ID: 2025_04_13_create_mtgjson_tables
Revises: 2025_04_09_create_tcgplayer_categories_table
Create Date: 2025-04-13 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2025_04_13_create_mtgjson_tables'
down_revision = '2025_04_09_create_tcgplayer_categories_table'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Create mtgjson_cards table
op.create_table(
'mtgjson_cards',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('card_id', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('set_code', sa.String(), nullable=True),
sa.Column('uuid', sa.String(), nullable=True),
# Identifiers
sa.Column('abu_id', sa.String(), nullable=True),
sa.Column('card_kingdom_etched_id', sa.String(), nullable=True),
sa.Column('card_kingdom_foil_id', sa.String(), nullable=True),
sa.Column('card_kingdom_id', sa.String(), nullable=True),
sa.Column('cardsphere_id', sa.String(), nullable=True),
sa.Column('cardsphere_foil_id', sa.String(), nullable=True),
sa.Column('cardtrader_id', sa.String(), nullable=True),
sa.Column('csi_id', sa.String(), nullable=True),
sa.Column('mcm_id', sa.String(), nullable=True),
sa.Column('mcm_meta_id', sa.String(), nullable=True),
sa.Column('miniaturemarket_id', sa.String(), nullable=True),
sa.Column('mtg_arena_id', sa.String(), nullable=True),
sa.Column('mtgjson_foil_version_id', sa.String(), nullable=True),
sa.Column('mtgjson_non_foil_version_id', sa.String(), nullable=True),
sa.Column('mtgjson_v4_id', sa.String(), nullable=True),
sa.Column('mtgo_foil_id', sa.String(), nullable=True),
sa.Column('mtgo_id', sa.String(), nullable=True),
sa.Column('multiverse_id', sa.String(), nullable=True),
sa.Column('scg_id', sa.String(), nullable=True),
sa.Column('scryfall_id', sa.String(), nullable=True),
sa.Column('scryfall_card_back_id', sa.String(), nullable=True),
sa.Column('scryfall_oracle_id', sa.String(), nullable=True),
sa.Column('scryfall_illustration_id', sa.String(), nullable=True),
sa.Column('tcgplayer_product_id', sa.String(), nullable=True),
sa.Column('tcgplayer_etched_product_id', sa.String(), nullable=True),
sa.Column('tnt_id', sa.String(), nullable=True),
sa.Column('data', sa.JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_mtgjson_cards_card_id'), 'mtgjson_cards', ['card_id'], unique=True)
op.create_index(op.f('ix_mtgjson_cards_id'), 'mtgjson_cards', ['id'], unique=False)
# Create mtgjson_skus table
op.create_table(
'mtgjson_skus',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('sku_id', sa.String(), nullable=False),
sa.Column('product_id', sa.String(), nullable=True),
sa.Column('condition', sa.String(), nullable=True),
sa.Column('finish', sa.String(), nullable=True),
sa.Column('language', sa.String(), nullable=True),
sa.Column('printing', sa.String(), nullable=True),
sa.Column('card_id', sa.String(), nullable=True),
sa.Column('data', sa.JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_mtgjson_skus_card_id'), 'mtgjson_skus', ['card_id'], unique=False)
op.create_index(op.f('ix_mtgjson_skus_id'), 'mtgjson_skus', ['id'], unique=False)
op.create_index(op.f('ix_mtgjson_skus_product_id'), 'mtgjson_skus', ['product_id'], unique=False)
op.create_index(op.f('ix_mtgjson_skus_sku_id'), 'mtgjson_skus', ['sku_id'], unique=False)
def downgrade() -> None:
# Drop mtgjson_skus table first due to foreign key constraint
op.drop_index(op.f('ix_mtgjson_skus_sku_id'), table_name='mtgjson_skus')
op.drop_index(op.f('ix_mtgjson_skus_product_id'), table_name='mtgjson_skus')
op.drop_index(op.f('ix_mtgjson_skus_id'), table_name='mtgjson_skus')
op.drop_index(op.f('ix_mtgjson_skus_card_id'), table_name='mtgjson_skus')
op.drop_table('mtgjson_skus')
# Drop mtgjson_cards table
op.drop_index(op.f('ix_mtgjson_cards_id'), table_name='mtgjson_cards')
op.drop_index(op.f('ix_mtgjson_cards_card_id'), table_name='mtgjson_cards')
op.drop_table('mtgjson_cards')

View File

@@ -1,29 +0,0 @@
"""fix alembic version table
Revision ID: 2025_04_14_fix_alembic_version
Revises: 4dbeb89dd33a
Create Date: 2025-04-14 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2025_04_14_fix_alembic_version'
down_revision = '4dbeb89dd33a'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Increase the size of version_num column in alembic_version table
op.alter_column('alembic_version', 'version_num',
existing_type=sa.String(32),
type_=sa.String(255))
def downgrade() -> None:
# Revert the column size back to 32
op.alter_column('alembic_version', 'version_num',
existing_type=sa.String(255),
type_=sa.String(32))

View File

@@ -1,32 +0,0 @@
"""fix foreign key issue
Revision ID: fix_foreign_key_issue
Revises: 5bf5f87793d7
Create Date: 2025-04-14 04:15:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'fix_foreign_key_issue'
down_revision: Union[str, None] = '5bf5f87793d7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Drop the foreign key constraint if it exists
op.execute('ALTER TABLE mtgjson_skus DROP CONSTRAINT IF EXISTS mtgjson_skus_card_id_fkey')
# Make the column nullable
op.alter_column('mtgjson_skus', 'card_id',
existing_type=sa.String(),
nullable=True)
def downgrade() -> None:
# No downgrade - we don't want to recreate the constraint
pass

View File

@@ -1,33 +0,0 @@
"""fix mtgjson final
Revision ID: 2025_04_14_fix_mtgjson_final
Revises: d1628d8feb57
Create Date: 2025-04-14 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2025_04_14_fix_mtgjson_final'
down_revision = 'd1628d8feb57'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Drop the foreign key constraint and make card_id nullable
op.drop_constraint('mtgjson_skus_card_id_fkey', 'mtgjson_skus', type_='foreignkey')
op.alter_column('mtgjson_skus', 'card_id',
existing_type=sa.String(),
nullable=True)
def downgrade() -> None:
# Make card_id not nullable and recreate foreign key
op.alter_column('mtgjson_skus', 'card_id',
existing_type=sa.String(),
nullable=False)
op.create_foreign_key('mtgjson_skus_card_id_fkey',
'mtgjson_skus', 'mtgjson_cards',
['card_id'], ['card_id'])

View File

@@ -1,33 +0,0 @@
"""fix mtgjson foreign key
Revision ID: 2025_04_14_fix_mtgjson_foreign_key
Revises: 4ad81b486caf
Create Date: 2025-04-14 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2025_04_14_fix_mtgjson_foreign_key'
down_revision = '4ad81b486caf'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Drop the foreign key constraint and make card_id nullable
op.execute('ALTER TABLE mtgjson_skus DROP CONSTRAINT IF EXISTS mtgjson_skus_card_id_fkey')
op.alter_column('mtgjson_skus', 'card_id',
existing_type=sa.String(),
nullable=True)
def downgrade() -> None:
# Make card_id not nullable and recreate foreign key
op.alter_column('mtgjson_skus', 'card_id',
existing_type=sa.String(),
nullable=False)
op.create_foreign_key('mtgjson_skus_card_id_fkey',
'mtgjson_skus', 'mtgjson_cards',
['card_id'], ['card_id'])

View File

@@ -1,35 +0,0 @@
"""remove mtgjson data columns
Revision ID: 2025_04_14_remove_mtgjson_data_columns
Revises: 2025_04_13_create_mtgjson_tables
Create Date: 2025-04-14 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2025_04_14_remove_mtgjson_data_columns'
down_revision = '2025_04_13_create_mtgjson_tables'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Remove data column from mtgjson_skus table
op.drop_column('mtgjson_skus', 'data')
# Remove data column from mtgjson_cards table
op.drop_column('mtgjson_cards', 'data')
def downgrade() -> None:
# Add data column back to mtgjson_cards table
op.add_column('mtgjson_cards',
sa.Column('data', sa.JSON(), nullable=True)
)
# Add data column back to mtgjson_skus table
op.add_column('mtgjson_skus',
sa.Column('data', sa.JSON(), nullable=True)
)

View File

@@ -1,31 +0,0 @@
"""remove mtgjson foreign key constraint
Revision ID: 2025_04_14_remove_mtgjson_foreign_key
Revises: 2025_04_14_remove_mtgjson_data_columns
Create Date: 2025-04-14 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2025_04_14_remove_mtgjson_foreign_key'
down_revision = '2025_04_14_remove_mtgjson_data_columns'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Drop the foreign key constraint from mtgjson_skus table
op.drop_constraint('mtgjson_skus_card_id_fkey', 'mtgjson_skus', type_='foreignkey')
def downgrade() -> None:
# Recreate the foreign key constraint
op.create_foreign_key(
'mtgjson_skus_card_id_fkey',
'mtgjson_skus',
'mtgjson_cards',
['card_id'],
['card_id']
)

View File

@@ -0,0 +1,369 @@
"""i hate alembic so goddamn much
Revision ID: 479003fbead7
Revises:
Create Date: 2025-04-17 12:08:13.714276
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '479003fbead7'
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:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('cards',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('rarity', sa.String(), nullable=True),
sa.Column('set_name', sa.String(), nullable=True),
sa.Column('price', sa.Float(), nullable=True),
sa.Column('quantity', sa.Integer(), nullable=True),
sa.Column('tcgplayer_sku', sa.String(), nullable=True),
sa.Column('product_line', sa.String(), nullable=True),
sa.Column('product_name', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('number', sa.String(), nullable=True),
sa.Column('condition', sa.String(), nullable=True),
sa.Column('tcg_market_price', sa.Float(), nullable=True),
sa.Column('tcg_direct_low', sa.Float(), nullable=True),
sa.Column('tcg_low_price_with_shipping', sa.Float(), nullable=True),
sa.Column('tcg_low_price', sa.Float(), nullable=True),
sa.Column('total_quantity', sa.Integer(), nullable=True),
sa.Column('add_to_quantity', sa.Integer(), nullable=True),
sa.Column('tcg_marketplace_price', sa.Float(), nullable=True),
sa.Column('photo_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_cards_id'), 'cards', ['id'], unique=False)
op.create_index(op.f('ix_cards_name'), 'cards', ['name'], unique=False)
op.create_index(op.f('ix_cards_set_name'), 'cards', ['set_name'], unique=False)
op.create_index(op.f('ix_cards_tcgplayer_sku'), 'cards', ['tcgplayer_sku'], unique=True)
op.create_table('files',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('file_type', sa.String(), nullable=True),
sa.Column('content_type', sa.String(), nullable=True),
sa.Column('path', sa.String(), nullable=True),
sa.Column('size', sa.Integer(), nullable=True),
sa.Column('file_metadata', sa.JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_files_id'), 'files', ['id'], unique=False)
op.create_table('games',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_games_id'), 'games', ['id'], unique=False)
op.create_table('inventory',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tcgplayer_id', sa.String(), nullable=True),
sa.Column('product_line', sa.String(), nullable=True),
sa.Column('set_name', sa.String(), nullable=True),
sa.Column('product_name', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('number', sa.String(), nullable=True),
sa.Column('rarity', sa.String(), nullable=True),
sa.Column('condition', sa.String(), nullable=True),
sa.Column('tcg_market_price', sa.Float(), nullable=True),
sa.Column('tcg_direct_low', sa.Float(), nullable=True),
sa.Column('tcg_low_price_with_shipping', sa.Float(), nullable=True),
sa.Column('tcg_low_price', sa.Float(), nullable=True),
sa.Column('total_quantity', sa.Integer(), nullable=True),
sa.Column('add_to_quantity', sa.Integer(), nullable=True),
sa.Column('tcg_marketplace_price', sa.Float(), nullable=True),
sa.Column('photo_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_inventory_id'), 'inventory', ['id'], unique=False)
op.create_index(op.f('ix_inventory_tcgplayer_id'), 'inventory', ['tcgplayer_id'], unique=True)
op.create_table('mtgjson_cards',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('card_id', sa.String(), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('set_code', sa.String(), nullable=True),
sa.Column('uuid', sa.String(), nullable=True),
sa.Column('abu_id', sa.String(), nullable=True),
sa.Column('card_kingdom_etched_id', sa.String(), nullable=True),
sa.Column('card_kingdom_foil_id', sa.String(), nullable=True),
sa.Column('card_kingdom_id', sa.String(), nullable=True),
sa.Column('cardsphere_id', sa.String(), nullable=True),
sa.Column('cardsphere_foil_id', sa.String(), nullable=True),
sa.Column('cardtrader_id', sa.String(), nullable=True),
sa.Column('csi_id', sa.String(), nullable=True),
sa.Column('mcm_id', sa.String(), nullable=True),
sa.Column('mcm_meta_id', sa.String(), nullable=True),
sa.Column('miniaturemarket_id', sa.String(), nullable=True),
sa.Column('mtg_arena_id', sa.String(), nullable=True),
sa.Column('mtgjson_foil_version_id', sa.String(), nullable=True),
sa.Column('mtgjson_non_foil_version_id', sa.String(), nullable=True),
sa.Column('mtgjson_v4_id', sa.String(), nullable=True),
sa.Column('mtgo_foil_id', sa.String(), nullable=True),
sa.Column('mtgo_id', sa.String(), nullable=True),
sa.Column('multiverse_id', sa.String(), nullable=True),
sa.Column('scg_id', sa.String(), nullable=True),
sa.Column('scryfall_id', sa.String(), nullable=True),
sa.Column('scryfall_card_back_id', sa.String(), nullable=True),
sa.Column('scryfall_oracle_id', sa.String(), nullable=True),
sa.Column('scryfall_illustration_id', sa.String(), nullable=True),
sa.Column('tcgplayer_product_id', sa.String(), nullable=True),
sa.Column('tcgplayer_etched_product_id', sa.String(), nullable=True),
sa.Column('tnt_id', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_mtgjson_cards_card_id'), 'mtgjson_cards', ['card_id'], unique=True)
op.create_index(op.f('ix_mtgjson_cards_id'), 'mtgjson_cards', ['id'], unique=False)
op.create_table('mtgjson_skus',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('sku_id', sa.String(), nullable=True),
sa.Column('product_id', sa.String(), nullable=True),
sa.Column('condition', sa.String(), nullable=True),
sa.Column('finish', sa.String(), nullable=True),
sa.Column('language', sa.String(), nullable=True),
sa.Column('printing', sa.String(), nullable=True),
sa.Column('card_id', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_mtgjson_skus_id'), 'mtgjson_skus', ['id'], unique=False)
op.create_index(op.f('ix_mtgjson_skus_product_id'), 'mtgjson_skus', ['product_id'], unique=False)
op.create_index(op.f('ix_mtgjson_skus_sku_id'), 'mtgjson_skus', ['sku_id'], unique=False)
op.create_table('tcgplayer_categories',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=False),
sa.Column('display_name', sa.String(), nullable=True),
sa.Column('seo_category_name', sa.String(), nullable=True),
sa.Column('category_description', sa.String(), nullable=True),
sa.Column('category_page_title', sa.String(), nullable=True),
sa.Column('sealed_label', sa.String(), nullable=True),
sa.Column('non_sealed_label', sa.String(), nullable=True),
sa.Column('condition_guide_url', sa.String(), nullable=True),
sa.Column('is_scannable', sa.Boolean(), nullable=True),
sa.Column('popularity', sa.Integer(), nullable=True),
sa.Column('is_direct', sa.Boolean(), nullable=True),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_categories_category_id'), 'tcgplayer_categories', ['category_id'], unique=True)
op.create_index(op.f('ix_tcgplayer_categories_id'), 'tcgplayer_categories', ['id'], unique=False)
op.create_table('tcgplayer_groups',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=False),
sa.Column('abbreviation', sa.String(), nullable=True),
sa.Column('is_supplemental', sa.Boolean(), nullable=True),
sa.Column('published_on', sa.DateTime(), nullable=True),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_groups_group_id'), 'tcgplayer_groups', ['group_id'], unique=True)
op.create_index(op.f('ix_tcgplayer_groups_id'), 'tcgplayer_groups', ['id'], unique=False)
op.create_table('tcgplayer_order_products',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('product_name', sa.String(), nullable=True),
sa.Column('unit_price', sa.Float(), nullable=True),
sa.Column('extended_price', sa.Float(), nullable=True),
sa.Column('quantity', sa.Integer(), nullable=True),
sa.Column('url', sa.String(), nullable=True),
sa.Column('product_id', sa.String(), nullable=True),
sa.Column('sku_id', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_order_products_id'), 'tcgplayer_order_products', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_order_products_order_number'), 'tcgplayer_order_products', ['order_number'], unique=False)
op.create_table('tcgplayer_order_refunds',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('refund_created_at', sa.DateTime(), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.Column('amount', sa.Float(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('origin', sa.String(), nullable=True),
sa.Column('shipping_amount', sa.Float(), nullable=True),
sa.Column('products', sa.JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_order_refunds_id'), 'tcgplayer_order_refunds', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_order_refunds_order_number'), 'tcgplayer_order_refunds', ['order_number'], unique=False)
op.create_table('tcgplayer_order_transactions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('product_amount', sa.Float(), nullable=True),
sa.Column('shipping_amount', sa.Float(), nullable=True),
sa.Column('gross_amount', sa.Float(), nullable=True),
sa.Column('fee_amount', sa.Float(), nullable=True),
sa.Column('net_amount', sa.Float(), nullable=True),
sa.Column('direct_fee_amount', sa.Float(), nullable=True),
sa.Column('taxes', sa.JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_order_transactions_id'), 'tcgplayer_order_transactions', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_order_transactions_order_number'), 'tcgplayer_order_transactions', ['order_number'], unique=False)
op.create_table('tcgplayer_orders',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('order_created_at', sa.DateTime(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
sa.Column('channel', sa.String(), nullable=True),
sa.Column('fulfillment', sa.String(), nullable=True),
sa.Column('seller_name', sa.String(), nullable=True),
sa.Column('buyer_name', sa.String(), nullable=True),
sa.Column('payment_type', sa.String(), nullable=True),
sa.Column('pickup_status', sa.String(), nullable=True),
sa.Column('shipping_type', sa.String(), nullable=True),
sa.Column('estimated_delivery_date', sa.DateTime(), nullable=True),
sa.Column('recipient_name', sa.String(), nullable=True),
sa.Column('address_line_1', sa.String(), nullable=True),
sa.Column('address_line_2', sa.String(), nullable=True),
sa.Column('city', sa.String(), nullable=True),
sa.Column('state', sa.String(), nullable=True),
sa.Column('zip_code', sa.String(), nullable=True),
sa.Column('country', sa.String(), nullable=True),
sa.Column('tracking_numbers', sa.JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_orders_id'), 'tcgplayer_orders', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_orders_order_number'), 'tcgplayer_orders', ['order_number'], unique=False)
op.create_table('boxes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.Column('set_code', sa.String(), nullable=True),
sa.Column('sku', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('game_id', sa.Integer(), nullable=True),
sa.Column('expected_number_of_cards', sa.Integer(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(['game_id'], ['games.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_boxes_id'), 'boxes', ['id'], unique=False)
op.create_table('tcgplayer_products',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=False),
sa.Column('clean_name', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('url', sa.String(), nullable=True),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('image_count', sa.Integer(), nullable=True),
sa.Column('ext_rarity', sa.String(), nullable=True),
sa.Column('ext_number', sa.String(), nullable=True),
sa.Column('low_price', sa.Float(), nullable=True),
sa.Column('mid_price', sa.Float(), nullable=True),
sa.Column('high_price', sa.Float(), nullable=True),
sa.Column('market_price', sa.Float(), nullable=True),
sa.Column('direct_low_price', sa.Float(), nullable=True),
sa.Column('sub_type_name', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(['group_id'], ['tcgplayer_groups.group_id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_products_id'), 'tcgplayer_products', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_products_product_id'), 'tcgplayer_products', ['product_id'], unique=False)
op.create_table('open_boxes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('box_id', sa.Integer(), nullable=True),
sa.Column('number_of_cards', sa.Integer(), nullable=True),
sa.Column('date_opened', sa.DateTime(timezone=True), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(['box_id'], ['boxes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_open_boxes_id'), 'open_boxes', ['id'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_open_boxes_id'), table_name='open_boxes')
op.drop_table('open_boxes')
op.drop_index(op.f('ix_tcgplayer_products_product_id'), table_name='tcgplayer_products')
op.drop_index(op.f('ix_tcgplayer_products_id'), table_name='tcgplayer_products')
op.drop_table('tcgplayer_products')
op.drop_index(op.f('ix_boxes_id'), table_name='boxes')
op.drop_table('boxes')
op.drop_index(op.f('ix_tcgplayer_orders_order_number'), table_name='tcgplayer_orders')
op.drop_index(op.f('ix_tcgplayer_orders_id'), table_name='tcgplayer_orders')
op.drop_table('tcgplayer_orders')
op.drop_index(op.f('ix_tcgplayer_order_transactions_order_number'), table_name='tcgplayer_order_transactions')
op.drop_index(op.f('ix_tcgplayer_order_transactions_id'), table_name='tcgplayer_order_transactions')
op.drop_table('tcgplayer_order_transactions')
op.drop_index(op.f('ix_tcgplayer_order_refunds_order_number'), table_name='tcgplayer_order_refunds')
op.drop_index(op.f('ix_tcgplayer_order_refunds_id'), table_name='tcgplayer_order_refunds')
op.drop_table('tcgplayer_order_refunds')
op.drop_index(op.f('ix_tcgplayer_order_products_order_number'), table_name='tcgplayer_order_products')
op.drop_index(op.f('ix_tcgplayer_order_products_id'), table_name='tcgplayer_order_products')
op.drop_table('tcgplayer_order_products')
op.drop_index(op.f('ix_tcgplayer_groups_id'), table_name='tcgplayer_groups')
op.drop_index(op.f('ix_tcgplayer_groups_group_id'), table_name='tcgplayer_groups')
op.drop_table('tcgplayer_groups')
op.drop_index(op.f('ix_tcgplayer_categories_id'), table_name='tcgplayer_categories')
op.drop_index(op.f('ix_tcgplayer_categories_category_id'), table_name='tcgplayer_categories')
op.drop_table('tcgplayer_categories')
op.drop_index(op.f('ix_mtgjson_skus_sku_id'), table_name='mtgjson_skus')
op.drop_index(op.f('ix_mtgjson_skus_product_id'), table_name='mtgjson_skus')
op.drop_index(op.f('ix_mtgjson_skus_id'), table_name='mtgjson_skus')
op.drop_table('mtgjson_skus')
op.drop_index(op.f('ix_mtgjson_cards_id'), table_name='mtgjson_cards')
op.drop_index(op.f('ix_mtgjson_cards_card_id'), table_name='mtgjson_cards')
op.drop_table('mtgjson_cards')
op.drop_index(op.f('ix_inventory_tcgplayer_id'), table_name='inventory')
op.drop_index(op.f('ix_inventory_id'), table_name='inventory')
op.drop_table('inventory')
op.drop_index(op.f('ix_games_id'), table_name='games')
op.drop_table('games')
op.drop_index(op.f('ix_files_id'), table_name='files')
op.drop_table('files')
op.drop_index(op.f('ix_cards_tcgplayer_sku'), table_name='cards')
op.drop_index(op.f('ix_cards_set_name'), table_name='cards')
op.drop_index(op.f('ix_cards_name'), table_name='cards')
op.drop_index(op.f('ix_cards_id'), table_name='cards')
op.drop_table('cards')
# ### end Alembic commands ###

View File

@@ -1,26 +0,0 @@
"""merge heads
Revision ID: 4ad81b486caf
Revises: 2025_04_14_remove_mtgjson_data_columns, 8764850e4e35
Create Date: 2025-04-12 23:38:27.257987
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '4ad81b486caf'
down_revision: Union[str, None] = ('2025_04_14_remove_mtgjson_data_columns', '8764850e4e35')
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
pass
def downgrade() -> None:
pass

View File

@@ -1,171 +0,0 @@
"""create inventory table
Revision ID: 4dbeb89dd33a
Revises:
Create Date: 2025-04-09 21:56:49.068087
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '4dbeb89dd33a'
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('boxes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.Column('set_code', sa.String(), nullable=True),
sa.Column('sku', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=True),
sa.Column('expected_number_of_cards', sa.Integer(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_boxes_id'), 'boxes', ['id'], unique=False)
op.create_table('cards',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('rarity', sa.String(), nullable=True),
sa.Column('set_name', sa.String(), nullable=True),
sa.Column('price', sa.Float(), nullable=True),
sa.Column('quantity', sa.Integer(), nullable=True),
sa.Column('tcgplayer_sku', sa.String(), nullable=True),
sa.Column('product_line', sa.String(), nullable=True),
sa.Column('product_name', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('number', sa.String(), nullable=True),
sa.Column('condition', sa.String(), nullable=True),
sa.Column('tcg_market_price', sa.Float(), nullable=True),
sa.Column('tcg_direct_low', sa.Float(), nullable=True),
sa.Column('tcg_low_price_with_shipping', sa.Float(), nullable=True),
sa.Column('tcg_low_price', sa.Float(), nullable=True),
sa.Column('total_quantity', sa.Integer(), nullable=True),
sa.Column('add_to_quantity', sa.Integer(), nullable=True),
sa.Column('tcg_marketplace_price', sa.Float(), nullable=True),
sa.Column('photo_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_cards_id'), 'cards', ['id'], unique=False)
op.create_index(op.f('ix_cards_name'), 'cards', ['name'], unique=False)
op.create_index(op.f('ix_cards_set_name'), 'cards', ['set_name'], unique=False)
op.create_index(op.f('ix_cards_tcgplayer_sku'), 'cards', ['tcgplayer_sku'], unique=True)
op.create_table('files',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.Column('path', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_files_id'), 'files', ['id'], unique=False)
op.create_table('games',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_games_id'), 'games', ['id'], unique=False)
op.create_table('inventory',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('tcgplayer_id', sa.String(), nullable=True),
sa.Column('product_line', sa.String(), nullable=True),
sa.Column('set_name', sa.String(), nullable=True),
sa.Column('product_name', sa.String(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('number', sa.String(), nullable=True),
sa.Column('rarity', sa.String(), nullable=True),
sa.Column('condition', sa.String(), nullable=True),
sa.Column('tcg_market_price', sa.Float(), nullable=True),
sa.Column('tcg_direct_low', sa.Float(), nullable=True),
sa.Column('tcg_low_price_with_shipping', sa.Float(), nullable=True),
sa.Column('tcg_low_price', sa.Float(), nullable=True),
sa.Column('total_quantity', sa.Integer(), nullable=True),
sa.Column('add_to_quantity', sa.Integer(), nullable=True),
sa.Column('tcg_marketplace_price', sa.Float(), nullable=True),
sa.Column('photo_url', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_inventory_id'), 'inventory', ['id'], unique=False)
op.create_index(op.f('ix_inventory_tcgplayer_id'), 'inventory', ['tcgplayer_id'], unique=True)
op.create_table('open_boxes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('box_id', sa.Integer(), nullable=True),
sa.Column('number_of_cards', sa.Integer(), nullable=True),
sa.Column('date_opened', sa.DateTime(timezone=True), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.ForeignKeyConstraint(['box_id'], ['boxes.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_open_boxes_id'), 'open_boxes', ['id'], unique=False)
op.create_table('tcgplayer_products',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('clean_name', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('url', sa.String(), nullable=True),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('image_count', sa.Integer(), nullable=True),
sa.Column('ext_rarity', sa.String(), nullable=True),
sa.Column('ext_number', sa.String(), nullable=True),
sa.Column('low_price', sa.Float(), nullable=True),
sa.Column('mid_price', sa.Float(), nullable=True),
sa.Column('high_price', sa.Float(), nullable=True),
sa.Column('market_price', sa.Float(), nullable=True),
sa.Column('direct_low_price', sa.Float(), nullable=True),
sa.Column('sub_type_name', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('product_id')
)
op.create_index(op.f('ix_tcgplayer_products_id'), 'tcgplayer_products', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_products_product_id'), 'tcgplayer_products', ['product_id'], unique=True)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_tcgplayer_products_product_id'), table_name='tcgplayer_products')
op.drop_index(op.f('ix_tcgplayer_products_id'), table_name='tcgplayer_products')
op.drop_index(op.f('ix_open_boxes_id'), table_name='open_boxes')
op.drop_table('open_boxes')
op.drop_index(op.f('ix_inventory_tcgplayer_id'), table_name='inventory')
op.drop_index(op.f('ix_inventory_id'), table_name='inventory')
op.drop_table('inventory')
op.drop_index(op.f('ix_games_id'), table_name='games')
op.drop_table('games')
op.drop_index(op.f('ix_files_id'), table_name='files')
op.drop_table('files')
op.drop_index(op.f('ix_cards_tcgplayer_sku'), table_name='cards')
op.drop_index(op.f('ix_cards_set_name'), table_name='cards')
op.drop_index(op.f('ix_cards_name'), table_name='cards')
op.drop_index(op.f('ix_cards_id'), table_name='cards')
op.drop_table('cards')
op.drop_index(op.f('ix_boxes_id'), table_name='boxes')
op.drop_table('boxes')
# ### end Alembic commands ###

View File

@@ -1,26 +0,0 @@
"""merge all heads
Revision ID: 5bf5f87793d7
Revises: 2025_04_14_fix_alembic_version, 2025_04_14_fix_mtgjson_final
Create Date: 2025-04-13 00:12:47.613416
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '5bf5f87793d7'
down_revision: Union[str, None] = ('2025_04_14_fix_alembic_version', '2025_04_14_fix_mtgjson_final')
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
pass
def downgrade() -> None:
pass

View File

@@ -1,126 +0,0 @@
"""create_tcgplayer_order_tables
Revision ID: 6f2b3f870fdf
Revises: fix_foreign_key_issue
Create Date: 2025-04-16 20:19:01.698636
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSON
# revision identifiers, used by Alembic.
revision: str = '6f2b3f870fdf'
down_revision: Union[str, None] = 'fix_foreign_key_issue'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Create tcgplayer_orders table
op.create_table(
'tcgplayer_orders',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('order_created_at', sa.DateTime(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
sa.Column('channel', sa.String(), nullable=True),
sa.Column('fulfillment', sa.String(), nullable=True),
sa.Column('seller_name', sa.String(), nullable=True),
sa.Column('buyer_name', sa.String(), nullable=True),
sa.Column('payment_type', sa.String(), nullable=True),
sa.Column('pickup_status', sa.String(), nullable=True),
sa.Column('shipping_type', sa.String(), nullable=True),
sa.Column('estimated_delivery_date', sa.DateTime(), nullable=True),
sa.Column('recipient_name', sa.String(), nullable=True),
sa.Column('address_line_1', sa.String(), nullable=True),
sa.Column('address_line_2', sa.String(), nullable=True),
sa.Column('city', sa.String(), nullable=True),
sa.Column('state', sa.String(), nullable=True),
sa.Column('zip_code', sa.String(), nullable=True),
sa.Column('country', sa.String(), nullable=True),
sa.Column('tracking_numbers', JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_orders_id'), 'tcgplayer_orders', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_orders_order_number'), 'tcgplayer_orders', ['order_number'], unique=False)
# Create tcgplayer_order_transactions table
op.create_table(
'tcgplayer_order_transactions',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('product_amount', sa.Float(), nullable=True),
sa.Column('shipping_amount', sa.Float(), nullable=True),
sa.Column('gross_amount', sa.Float(), nullable=True),
sa.Column('fee_amount', sa.Float(), nullable=True),
sa.Column('net_amount', sa.Float(), nullable=True),
sa.Column('direct_fee_amount', sa.Float(), nullable=True),
sa.Column('taxes', JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_order_transactions_id'), 'tcgplayer_order_transactions', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_order_transactions_order_number'), 'tcgplayer_order_transactions', ['order_number'], unique=False)
# Create tcgplayer_order_products table
op.create_table(
'tcgplayer_order_products',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('product_name', sa.String(), nullable=True),
sa.Column('unit_price', sa.Float(), nullable=True),
sa.Column('extended_price', sa.Float(), nullable=True),
sa.Column('quantity', sa.Integer(), nullable=True),
sa.Column('url', sa.String(), nullable=True),
sa.Column('product_id', sa.String(), nullable=True),
sa.Column('sku_id', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_order_products_id'), 'tcgplayer_order_products', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_order_products_order_number'), 'tcgplayer_order_products', ['order_number'], unique=False)
# Create tcgplayer_order_refunds table
op.create_table(
'tcgplayer_order_refunds',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('order_number', sa.String(), nullable=True),
sa.Column('refund_created_at', sa.DateTime(), nullable=True),
sa.Column('type', sa.String(), nullable=True),
sa.Column('amount', sa.Float(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('origin', sa.String(), nullable=True),
sa.Column('shipping_amount', sa.Float(), nullable=True),
sa.Column('products', JSON(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_tcgplayer_order_refunds_id'), 'tcgplayer_order_refunds', ['id'], unique=False)
op.create_index(op.f('ix_tcgplayer_order_refunds_order_number'), 'tcgplayer_order_refunds', ['order_number'], unique=False)
def downgrade() -> None:
op.drop_index(op.f('ix_tcgplayer_order_refunds_order_number'), table_name='tcgplayer_order_refunds')
op.drop_index(op.f('ix_tcgplayer_order_refunds_id'), table_name='tcgplayer_order_refunds')
op.drop_table('tcgplayer_order_refunds')
op.drop_index(op.f('ix_tcgplayer_order_products_order_number'), table_name='tcgplayer_order_products')
op.drop_index(op.f('ix_tcgplayer_order_products_id'), table_name='tcgplayer_order_products')
op.drop_table('tcgplayer_order_products')
op.drop_index(op.f('ix_tcgplayer_order_transactions_order_number'), table_name='tcgplayer_order_transactions')
op.drop_index(op.f('ix_tcgplayer_order_transactions_id'), table_name='tcgplayer_order_transactions')
op.drop_table('tcgplayer_order_transactions')
op.drop_index(op.f('ix_tcgplayer_orders_order_number'), table_name='tcgplayer_orders')
op.drop_index(op.f('ix_tcgplayer_orders_id'), table_name='tcgplayer_orders')
op.drop_table('tcgplayer_orders')

View File

@@ -1,26 +0,0 @@
"""merge heads
Revision ID: 8764850e4e35
Revises: 2025_04_13_create_mtgjson_tables, 2025_04_09_create_tcgplayer_categories_table
Create Date: 2025-04-12 23:16:47.846723
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '8764850e4e35'
down_revision: Union[str, None] = ('2025_04_13_create_mtgjson_tables', '2025_04_09_create_tcgplayer_categories_table')
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
pass
def downgrade() -> None:
pass

View File

@@ -1,26 +0,0 @@
"""merge heads
Revision ID: d1628d8feb57
Revises: 2025_04_14_fix_mtgjson_foreign_key, 2025_04_14_remove_mtgjson_foreign_key
Create Date: 2025-04-13 00:11:03.312552
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'd1628d8feb57'
down_revision: Union[str, None] = ('2025_04_14_fix_mtgjson_foreign_key', '2025_04_14_remove_mtgjson_foreign_key')
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
pass
def downgrade() -> None:
pass

View File

@@ -1,101 +0,0 @@
"""remove product_id unique constraint
Revision ID: remove_product_id_unique_constraint
Revises: 4dbeb89dd33a
Create Date: 2025-04-09 23:10:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'remove_product_id_unique_constraint'
down_revision: str = '4dbeb89dd33a'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Create a new table without the unique constraint
op.create_table('tcgplayer_products_new',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=False),
sa.Column('clean_name', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('url', sa.String(), nullable=True),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('image_count', sa.Integer(), nullable=True),
sa.Column('ext_rarity', sa.String(), nullable=True),
sa.Column('ext_number', sa.String(), nullable=True),
sa.Column('low_price', sa.Float(), nullable=True),
sa.Column('mid_price', sa.Float(), nullable=True),
sa.Column('high_price', sa.Float(), nullable=True),
sa.Column('market_price', sa.Float(), nullable=True),
sa.Column('direct_low_price', sa.Float(), nullable=True),
sa.Column('sub_type_name', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.ForeignKeyConstraint(['group_id'], ['tcgplayer_groups.group_id'])
)
# Copy data from old table to new table
op.execute('INSERT INTO tcgplayer_products_new SELECT * FROM tcgplayer_products')
# Drop old table
op.drop_table('tcgplayer_products')
# Rename new table to old table name
op.rename_table('tcgplayer_products_new', 'tcgplayer_products')
# Create indexes
op.create_index('ix_tcgplayer_products_id', 'tcgplayer_products', ['id'], unique=False)
op.create_index('ix_tcgplayer_products_product_id', 'tcgplayer_products', ['product_id'], unique=False)
def downgrade() -> None:
# Create a new table with the unique constraint
op.create_table('tcgplayer_products_new',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=True),
sa.Column('name', sa.String(), nullable=False),
sa.Column('clean_name', sa.String(), nullable=True),
sa.Column('image_url', sa.String(), nullable=True),
sa.Column('category_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('url', sa.String(), nullable=True),
sa.Column('modified_on', sa.DateTime(), nullable=True),
sa.Column('image_count', sa.Integer(), nullable=True),
sa.Column('ext_rarity', sa.String(), nullable=True),
sa.Column('ext_number', sa.String(), nullable=True),
sa.Column('low_price', sa.Float(), nullable=True),
sa.Column('mid_price', sa.Float(), nullable=True),
sa.Column('high_price', sa.Float(), nullable=True),
sa.Column('market_price', sa.Float(), nullable=True),
sa.Column('direct_low_price', sa.Float(), nullable=True),
sa.Column('sub_type_name', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('product_id'),
sa.ForeignKeyConstraint(['group_id'], ['tcgplayer_groups.group_id'])
)
# Copy data from old table to new table
op.execute('INSERT INTO tcgplayer_products_new SELECT * FROM tcgplayer_products')
# Drop old table
op.drop_table('tcgplayer_products')
# Rename new table to old table name
op.rename_table('tcgplayer_products_new', 'tcgplayer_products')
# Create indexes
op.create_index('ix_tcgplayer_products_id', 'tcgplayer_products', ['id'], unique=False)
op.create_index('ix_tcgplayer_products_product_id', 'tcgplayer_products', ['product_id'], unique=True)