initial commit of new version
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
||||
@@ -0,0 +1,78 @@
|
||||
from logging.config import fileConfig
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from alembic import context
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
target_metadata = None
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(
|
||||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection, target_metadata=target_metadata
|
||||
)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
@@ -0,0 +1,28 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
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"}
|
||||
@@ -0,0 +1,36 @@
|
||||
"""create image table
|
||||
|
||||
Revision ID: c0b336d0d88a
|
||||
Revises:
|
||||
Create Date: 2026-03-30 17:00:10.164166
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'c0b336d0d88a'
|
||||
down_revision: Union[str, Sequence[str], None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.create_table(
|
||||
'avdb_image',
|
||||
sa.Column('img_id', sa.Integer, primary_key=True),
|
||||
sa.Column('img_path', sa.Text, nullable=False, unique=True),
|
||||
sa.Column('img_name', sa.Text, nullable=False),
|
||||
sa.Column('width', sa.Integer, nullable=False),
|
||||
sa.Column('height', sa.Integer, nullable=False),
|
||||
sa.Column('created_at', sa.TIMESTAMP, server_default=sa.func.current_timestamp())
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_table('avdb_image')
|
||||
@@ -0,0 +1,44 @@
|
||||
"""create pyramid table
|
||||
|
||||
Revision ID: 37c302fcd3c3
|
||||
Revises: c0b336d0d88a
|
||||
Create Date: 2026-03-30 21:32:57.704245
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from pgvector.sqlalchemy import Vector
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '37c302fcd3c3'
|
||||
down_revision: Union[str, Sequence[str], None] = 'c0b336d0d88a'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.create_table(
|
||||
'pyramiddata',
|
||||
sa.Column('pyrdata_id', sa.BigInteger, primary_key=True),
|
||||
sa.Column('img_id', sa.Integer, nullable=False),
|
||||
sa.Column('level', sa.Integer, nullable=False),
|
||||
sa.Column('tilex', sa.Integer, nullable=False),
|
||||
sa.Column('tiley', sa.Integer, nullable=False),
|
||||
sa.Column('x', sa.Integer, nullable=False),
|
||||
sa.Column('y', sa.Integer, nullable=False),
|
||||
sa.Column('x0', sa.Integer, nullable=False),
|
||||
sa.Column('y0', sa.Integer, nullable=False),
|
||||
sa.Column('w', sa.Integer, nullable=False),
|
||||
sa.Column('h', sa.Integer, nullable=False),
|
||||
sa.Column('hash', sa.Text, nullable=False),
|
||||
sa.Column('histogram', Vector(48), nullable=True),
|
||||
sa.Column('tile_data', Vector(3), nullable=True),
|
||||
sa.Column('block_data', Vector(27), nullable=True)
|
||||
)
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_table('pyramiddata')
|
||||
@@ -0,0 +1,52 @@
|
||||
"""create second-order table
|
||||
|
||||
Revision ID: 6762186cc97c
|
||||
Revises: 37c302fcd3c3
|
||||
Create Date: 2026-04-23 16:48:07.206738
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from pgvector.sqlalchemy import Vector
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '6762186cc97c'
|
||||
down_revision: Union[str, Sequence[str], None] = '37c302fcd3c3'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.create_table(
|
||||
'pyramiddata_2tiles',
|
||||
sa.Column('pyrdata_id', sa.BigInteger, primary_key=True),
|
||||
sa.Column('img_id', sa.Integer, nullable=False),
|
||||
sa.Column('level', sa.Integer, nullable=False),
|
||||
sa.Column('tilex_a', sa.Integer, nullable=False),
|
||||
sa.Column('tiley_a', sa.Integer, nullable=False),
|
||||
sa.Column('x_a', sa.Integer, nullable=False),
|
||||
sa.Column('y_a', sa.Integer, nullable=False),
|
||||
sa.Column('x0_a', sa.Integer, nullable=False),
|
||||
sa.Column('y0_a', sa.Integer, nullable=False),
|
||||
sa.Column('w_a', sa.Integer, nullable=False),
|
||||
sa.Column('h_a', sa.Integer, nullable=False),
|
||||
sa.Column('tilex_b', sa.Integer, nullable=False),
|
||||
sa.Column('tiley_b', sa.Integer, nullable=False),
|
||||
sa.Column('x_b', sa.Integer, nullable=False),
|
||||
sa.Column('y_b', sa.Integer, nullable=False),
|
||||
sa.Column('x0_b', sa.Integer, nullable=False),
|
||||
sa.Column('y0_b', sa.Integer, nullable=False),
|
||||
sa.Column('w_b', sa.Integer, nullable=False),
|
||||
sa.Column('h_b', sa.Integer, nullable=False),
|
||||
sa.Column('hash', sa.Text, nullable=False),
|
||||
sa.Column('tile_data', Vector(6), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_table('pyramiddata_2tiles')
|
||||
@@ -0,0 +1,46 @@
|
||||
"""create level3 separate table
|
||||
|
||||
Revision ID: f750c5d057a7
|
||||
Revises: 6762186cc97c
|
||||
Create Date: 2026-05-05 00:52:23.600420
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from pgvector.sqlalchemy import Vector
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'f750c5d057a7'
|
||||
down_revision: Union[str, Sequence[str], None] = '6762186cc97c'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.create_table(
|
||||
'pyramiddata_level3',
|
||||
sa.Column('pyrdata_id', sa.BigInteger, primary_key=True),
|
||||
sa.Column('img_id', sa.Integer, nullable=False),
|
||||
sa.Column('level', sa.Integer, nullable=False),
|
||||
sa.Column('tilex', sa.Integer, nullable=False),
|
||||
sa.Column('tiley', sa.Integer, nullable=False),
|
||||
sa.Column('x', sa.Integer, nullable=False),
|
||||
sa.Column('y', sa.Integer, nullable=False),
|
||||
sa.Column('x0', sa.Integer, nullable=False),
|
||||
sa.Column('y0', sa.Integer, nullable=False),
|
||||
sa.Column('w', sa.Integer, nullable=False),
|
||||
sa.Column('h', sa.Integer, nullable=False),
|
||||
sa.Column('hash', sa.Text, nullable=False),
|
||||
sa.Column('histogram', Vector(48), nullable=True),
|
||||
sa.Column('tile_data', Vector(3), nullable=True),
|
||||
sa.Column('block_data', Vector(27), nullable=True)
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_table('pyramiddata_level3')
|
||||
Reference in New Issue
Block a user