mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-07 00:15:10 +01:00
Compare commits
2 Commits
8810a47faa
...
79be98abea
| Author | SHA1 | Date | |
|---|---|---|---|
| 79be98abea | |||
| a7498a2fba |
@@ -0,0 +1 @@
|
|||||||
|
"""Digimarks project."""
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
"""Alembic environment file for SQLAlchemy."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
@@ -7,7 +9,7 @@ from sqlalchemy.engine import Connection
|
|||||||
from sqlalchemy.ext.asyncio import async_engine_from_config
|
from sqlalchemy.ext.asyncio import async_engine_from_config
|
||||||
from sqlmodel import SQLModel
|
from sqlmodel import SQLModel
|
||||||
|
|
||||||
from src.digimarks.models import Bookmark, PublicTag, User
|
from src.digimarks.models import Bookmark, PublicTag, User # noqa
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
@@ -56,6 +58,7 @@ def run_migrations_offline() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def do_run_migrations(connection: Connection) -> None:
|
def do_run_migrations(connection: Connection) -> None:
|
||||||
|
"""Run the migrations."""
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection,
|
connection=connection,
|
||||||
target_metadata=target_metadata,
|
target_metadata=target_metadata,
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
"""Initial migration
|
"""Initial migration.
|
||||||
|
|
||||||
Revision ID: 115bcd2e1a38
|
Revision ID: 115bcd2e1a38
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2025-09-12 16:06:16.479075
|
Create Date: 2025-09-12 16:06:16.479075
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Sequence, Union
|
from typing import Sequence, Union
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = '115bcd2e1a38'
|
revision: str = '115bcd2e1a38'
|
||||||
@@ -21,7 +20,8 @@ depends_on: Union[str, Sequence[str], None] = None
|
|||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
"""Upgrade schema."""
|
"""Upgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.create_table('bookmark',
|
op.create_table(
|
||||||
|
'bookmark',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('userkey', sa.String(length=255), nullable=False),
|
sa.Column('userkey', sa.String(length=255), nullable=False),
|
||||||
sa.Column('title', sa.String(length=255), nullable=False),
|
sa.Column('title', sa.String(length=255), nullable=False),
|
||||||
@@ -36,23 +36,25 @@ def upgrade() -> None:
|
|||||||
sa.Column('deleted_date', sa.DateTime(), server_default=sa.text('(null)'), nullable=True),
|
sa.Column('deleted_date', sa.DateTime(), server_default=sa.text('(null)'), nullable=True),
|
||||||
sa.Column('status', sa.Integer(), server_default=sa.text('0'), nullable=True),
|
sa.Column('status', sa.Integer(), server_default=sa.text('0'), nullable=True),
|
||||||
sa.Column('note', sa.Text(), server_default=sa.text('(null)'), nullable=True),
|
sa.Column('note', sa.Text(), server_default=sa.text('(null)'), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id'),
|
||||||
)
|
)
|
||||||
op.create_table('publictag',
|
op.create_table(
|
||||||
|
'publictag',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('tagkey', sa.String(length=255), nullable=False),
|
sa.Column('tagkey', sa.String(length=255), nullable=False),
|
||||||
sa.Column('userkey', sa.String(length=255), nullable=False),
|
sa.Column('userkey', sa.String(length=255), nullable=False),
|
||||||
sa.Column('tag', sa.String(length=255), nullable=False),
|
sa.Column('tag', sa.String(length=255), nullable=False),
|
||||||
sa.Column('created_date', sa.DateTime(), server_default=sa.text('(null)'), nullable=True),
|
sa.Column('created_date', sa.DateTime(), server_default=sa.text('(null)'), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id'),
|
||||||
)
|
)
|
||||||
op.create_table('user',
|
op.create_table(
|
||||||
|
'user',
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
sa.Column('username', sa.String(length=255), nullable=False),
|
sa.Column('username', sa.String(length=255), nullable=False),
|
||||||
sa.Column('key', sa.String(length=255), nullable=False),
|
sa.Column('key', sa.String(length=255), nullable=False),
|
||||||
sa.Column('created_date', sa.DateTime(), nullable=False),
|
sa.Column('created_date', sa.DateTime(), nullable=False),
|
||||||
sa.Column('theme', sa.String(length=20), server_default=sa.text("'green'"), nullable=True),
|
sa.Column('theme', sa.String(length=20), server_default=sa.text("'green'"), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id'),
|
||||||
)
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
Revision ID: a8d8e45f60a1
|
Revision ID: a8d8e45f60a1
|
||||||
Revises: 115bcd2e1a38
|
Revises: 115bcd2e1a38
|
||||||
Create Date: 2025-09-12 16:10:41.378716
|
Create Date: 2025-09-12 16:10:41.378716
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from datetime import UTC, datetime
|
||||||
from typing import Sequence, Union
|
from typing import Sequence, Union
|
||||||
|
|
||||||
from alembic import op
|
|
||||||
from datetime import UTC, datetime
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlmodel
|
import sqlmodel
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = 'a8d8e45f60a1'
|
revision: str = 'a8d8e45f60a1'
|
||||||
@@ -24,72 +23,74 @@ def upgrade() -> None:
|
|||||||
"""Upgrade schema."""
|
"""Upgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
with op.batch_alter_table('bookmark', schema=None) as batch_op:
|
with op.batch_alter_table('bookmark', schema=None) as batch_op:
|
||||||
batch_op.alter_column('note',
|
batch_op.alter_column(
|
||||||
|
'note',
|
||||||
existing_type=sa.TEXT(),
|
existing_type=sa.TEXT(),
|
||||||
type_=sqlmodel.sql.sqltypes.AutoString(),
|
type_=sqlmodel.sql.sqltypes.AutoString(),
|
||||||
nullable=True,
|
nullable=True,
|
||||||
existing_server_default=sa.text('(null)'))
|
existing_server_default=sa.text('(null)'),
|
||||||
batch_op.alter_column('starred',
|
)
|
||||||
existing_type=sa.BOOLEAN(),
|
batch_op.alter_column(
|
||||||
nullable=False,
|
'starred', existing_type=sa.BOOLEAN(), nullable=False, existing_server_default=sa.text('0')
|
||||||
existing_server_default=sa.text('0'))
|
)
|
||||||
batch_op.alter_column('modified_date',
|
batch_op.alter_column('modified_date', existing_type=sa.DATETIME(), nullable=True)
|
||||||
existing_type=sa.DATETIME(),
|
batch_op.alter_column(
|
||||||
nullable=True)
|
'deleted_date', existing_type=sa.DATETIME(), nullable=True, existing_server_default=sa.text('(null)')
|
||||||
batch_op.alter_column('deleted_date',
|
)
|
||||||
existing_type=sa.DATETIME(),
|
batch_op.alter_column(
|
||||||
nullable=True,
|
'status', existing_type=sa.INTEGER(), nullable=False, existing_server_default=sa.text('0')
|
||||||
existing_server_default=sa.text('(null)'))
|
)
|
||||||
batch_op.alter_column('status',
|
|
||||||
existing_type=sa.INTEGER(),
|
|
||||||
nullable=False,
|
|
||||||
existing_server_default=sa.text('0'))
|
|
||||||
batch_op.create_foreign_key('bookmark_user', 'user', ['userkey'], ['key'])
|
batch_op.create_foreign_key('bookmark_user', 'user', ['userkey'], ['key'])
|
||||||
with op.batch_alter_table('publictag', schema=None) as batch_op:
|
with op.batch_alter_table('publictag', schema=None) as batch_op:
|
||||||
batch_op.alter_column('created_date',
|
batch_op.alter_column(
|
||||||
|
'created_date',
|
||||||
existing_type=sa.DATETIME(),
|
existing_type=sa.DATETIME(),
|
||||||
nullable=True,
|
nullable=True,
|
||||||
existing_server_default=sa.text(str(datetime.now(UTC))))
|
existing_server_default=sa.text(str(datetime.now(UTC))),
|
||||||
|
)
|
||||||
batch_op.create_foreign_key('publictag_user', 'user', ['userkey'], ['key'])
|
batch_op.create_foreign_key('publictag_user', 'user', ['userkey'], ['key'])
|
||||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||||
batch_op.alter_column('theme',
|
batch_op.alter_column(
|
||||||
existing_type=sa.VARCHAR(length=20),
|
'theme', existing_type=sa.VARCHAR(length=20), nullable=False, existing_server_default=sa.text("'green'")
|
||||||
nullable=False,
|
)
|
||||||
existing_server_default=sa.text("'green'"))
|
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
"""Downgrade schema."""
|
"""Downgrade schema."""
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
op.alter_column('user', 'theme',
|
op.alter_column(
|
||||||
existing_type=sa.VARCHAR(length=20),
|
'user', 'theme', existing_type=sa.VARCHAR(length=20), nullable=True, existing_server_default=sa.text("'green'")
|
||||||
nullable=True,
|
)
|
||||||
existing_server_default=sa.text("'green'"))
|
|
||||||
op.drop_constraint(None, 'publictag', type_='foreignkey')
|
op.drop_constraint(None, 'publictag', type_='foreignkey')
|
||||||
op.alter_column('publictag', 'created_date',
|
op.alter_column(
|
||||||
|
'publictag',
|
||||||
|
'created_date',
|
||||||
existing_type=sa.DATETIME(),
|
existing_type=sa.DATETIME(),
|
||||||
nullable=True,
|
nullable=True,
|
||||||
existing_server_default=sa.text('(null)'))
|
existing_server_default=sa.text('(null)'),
|
||||||
|
)
|
||||||
op.drop_constraint(None, 'bookmark', type_='foreignkey')
|
op.drop_constraint(None, 'bookmark', type_='foreignkey')
|
||||||
op.alter_column('bookmark', 'status',
|
op.alter_column(
|
||||||
existing_type=sa.INTEGER(),
|
'bookmark', 'status', existing_type=sa.INTEGER(), nullable=True, existing_server_default=sa.text('0')
|
||||||
nullable=True,
|
)
|
||||||
existing_server_default=sa.text('0'))
|
op.alter_column(
|
||||||
op.alter_column('bookmark', 'deleted_date',
|
'bookmark',
|
||||||
|
'deleted_date',
|
||||||
existing_type=sa.DATETIME(),
|
existing_type=sa.DATETIME(),
|
||||||
nullable=True,
|
nullable=True,
|
||||||
existing_server_default=sa.text('(null)'))
|
existing_server_default=sa.text('(null)'),
|
||||||
op.alter_column('bookmark', 'modified_date',
|
)
|
||||||
existing_type=sa.DATETIME(),
|
op.alter_column('bookmark', 'modified_date', existing_type=sa.DATETIME(), nullable=True)
|
||||||
nullable=True)
|
op.alter_column(
|
||||||
op.alter_column('bookmark', 'starred',
|
'bookmark', 'starred', existing_type=sa.BOOLEAN(), nullable=True, existing_server_default=sa.text('0')
|
||||||
existing_type=sa.BOOLEAN(),
|
)
|
||||||
nullable=True,
|
op.alter_column(
|
||||||
existing_server_default=sa.text('0'))
|
'bookmark',
|
||||||
op.alter_column('bookmark', 'note',
|
'note',
|
||||||
existing_type=sqlmodel.sql.sqltypes.AutoString(),
|
existing_type=sqlmodel.sql.sqltypes.AutoString(),
|
||||||
type_=sa.TEXT(),
|
type_=sa.TEXT(),
|
||||||
nullable=True,
|
nullable=True,
|
||||||
existing_server_default=sa.text('(null)'))
|
existing_server_default=sa.text('(null)'),
|
||||||
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
"""Renamed keys
|
"""Renamed keys.
|
||||||
|
|
||||||
Revision ID: b8cbc6957df5
|
Revision ID: b8cbc6957df5
|
||||||
Revises: a8d8e45f60a1
|
Revises: a8d8e45f60a1
|
||||||
Create Date: 2025-09-12 22:26:38.684120
|
Create Date: 2025-09-12 22:26:38.684120
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Sequence, Union
|
from typing import Sequence, Union
|
||||||
|
|
||||||
from alembic import op
|
from alembic import op
|
||||||
import sqlalchemy as sa
|
|
||||||
import sqlmodel
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = 'b8cbc6957df5'
|
revision: str = 'b8cbc6957df5'
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
"""digimarks main module."""
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
"""Top-level package for Digimarks."""
|
||||||
|
|
||||||
|
__author__ = """Michiel Scholten"""
|
||||||
|
|||||||
Reference in New Issue
Block a user