wip
This commit is contained in:
parent
8480cd3d24
commit
e86e432102
11 changed files with 352 additions and 69 deletions
|
|
@ -8,6 +8,9 @@ Create Date: ${create_date}
|
|||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
from learn_sql_model.er_diagram import generate_er_diagram, generate_er_markdown
|
||||
from learn_sql_model.config import get_config
|
||||
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
|
|
@ -19,6 +22,8 @@ depends_on = ${repr(depends_on)}
|
|||
|
||||
def upgrade() -> None:
|
||||
${upgrades if upgrades else "pass"}
|
||||
generate_er_diagram(f'migrations/versions/{revision}_er_diagram.png')
|
||||
generate_er_markdown(f'migrations/versions/{revision}_er_diagram.md', f'migrations/versions/er_diagram_{revision}.png')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
"""add x, y, size
|
||||
"""add x and y
|
||||
|
||||
Revision ID: e26398d96dd0
|
||||
Revises: a9bb6625c57b
|
||||
Create Date: 2023-06-10 18:37:04.751553
|
||||
Revision ID: 3555f61aaa79
|
||||
Revises: 79972ec5f79d
|
||||
Create Date: 2023-06-22 15:03:27.338959
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
from learn_sql_model.er_diagram import generate_er_diagram, generate_er_markdown
|
||||
from learn_sql_model.config import get_config
|
||||
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e26398d96dd0'
|
||||
down_revision = 'a9bb6625c57b'
|
||||
revision = '3555f61aaa79'
|
||||
down_revision = '79972ec5f79d'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
|
@ -21,13 +24,13 @@ def upgrade() -> None:
|
|||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('hero', sa.Column('x', sa.Integer(), nullable=False))
|
||||
op.add_column('hero', sa.Column('y', sa.Integer(), nullable=False))
|
||||
op.add_column('hero', sa.Column('size', sa.Integer(), nullable=False))
|
||||
# ### end Alembic commands ###
|
||||
generate_er_diagram(f'migrations/versions/{revision}_er_diagram.png')
|
||||
generate_er_markdown(f'migrations/versions/{revision}_er_diagram.md', f'migrations/versions/er_diagram_{revision}.png')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('hero', 'size')
|
||||
op.drop_column('hero', 'y')
|
||||
op.drop_column('hero', 'x')
|
||||
# ### end Alembic commands ###
|
||||
68
migrations/versions/3555f61aaa79_er_diagram.md
Normal file
68
migrations/versions/3555f61aaa79_er_diagram.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||

|
||||
|
||||
---
|
||||
|
||||
## Table: learn_sql_model_alembic_version
|
||||
|
||||
### First 5 rows
|
||||
|
||||
| version_num |
|
||||
|-------------|
|
||||
| 79972ec5f79d |
|
||||
|
||||
### Columns
|
||||
|
||||
| Column Name | Type | Foreign Key | Example Value |
|
||||
|-------------|------|-------------|---------------|
|
||||
| version_num | VARCHAR(32) | | | |
|
||||
|
||||
### Records Count
|
||||
|
||||
The table learn_sql_model_alembic_version contains 1 records.
|
||||
|
||||
---
|
||||
|
||||
## Table: hero
|
||||
|
||||
### First 5 rows
|
||||
|
||||
| name | secret_name | id | x | y |
|
||||
|------|-------------|----|---|---|
|
||||
|
||||
### Columns
|
||||
|
||||
| Column Name | Type | Foreign Key | Example Value |
|
||||
|-------------|------|-------------|---------------|
|
||||
| name | VARCHAR | | | |
|
||||
| secret_name | VARCHAR | | | |
|
||||
| id | INTEGER | | | |
|
||||
| x | INTEGER | | | |
|
||||
| y | INTEGER | | | |
|
||||
|
||||
### Records Count
|
||||
|
||||
The table hero contains 0 records.
|
||||
|
||||
---
|
||||
|
||||
## Table: pet
|
||||
|
||||
### First 5 rows
|
||||
|
||||
| name | birthday | id |
|
||||
|------|----------|----|
|
||||
|
||||
### Columns
|
||||
|
||||
| Column Name | Type | Foreign Key | Example Value |
|
||||
|-------------|------|-------------|---------------|
|
||||
| name | VARCHAR | | | |
|
||||
| birthday | DATETIME | | | |
|
||||
| id | INTEGER | | | |
|
||||
|
||||
### Records Count
|
||||
|
||||
The table pet contains 0 records.
|
||||
|
||||
---
|
||||
|
||||
BIN
migrations/versions/3555f61aaa79_er_diagram.png
Normal file
BIN
migrations/versions/3555f61aaa79_er_diagram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
65
migrations/versions/79972ec5f79d_er_diagram.md
Normal file
65
migrations/versions/79972ec5f79d_er_diagram.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||

|
||||
|
||||
---
|
||||
|
||||
## Table: learn_sql_model_alembic_version
|
||||
|
||||
### First 5 rows
|
||||
|
||||
| version_num |
|
||||
|-------------|
|
||||
|
||||
### Columns
|
||||
|
||||
| Column Name | Type | Foreign Key | Example Value |
|
||||
|-------------|------|-------------|---------------|
|
||||
| version_num | VARCHAR(32) | | | |
|
||||
|
||||
### Records Count
|
||||
|
||||
The table learn_sql_model_alembic_version contains 0 records.
|
||||
|
||||
---
|
||||
|
||||
## Table: hero
|
||||
|
||||
### First 5 rows
|
||||
|
||||
| name | secret_name | id |
|
||||
|------|-------------|----|
|
||||
|
||||
### Columns
|
||||
|
||||
| Column Name | Type | Foreign Key | Example Value |
|
||||
|-------------|------|-------------|---------------|
|
||||
| name | VARCHAR | | | |
|
||||
| secret_name | VARCHAR | | | |
|
||||
| id | INTEGER | | | |
|
||||
|
||||
### Records Count
|
||||
|
||||
The table hero contains 0 records.
|
||||
|
||||
---
|
||||
|
||||
## Table: pet
|
||||
|
||||
### First 5 rows
|
||||
|
||||
| name | birthday | id |
|
||||
|------|----------|----|
|
||||
|
||||
### Columns
|
||||
|
||||
| Column Name | Type | Foreign Key | Example Value |
|
||||
|-------------|------|-------------|---------------|
|
||||
| name | VARCHAR | | | |
|
||||
| birthday | DATETIME | | | |
|
||||
| id | INTEGER | | | |
|
||||
|
||||
### Records Count
|
||||
|
||||
The table pet contains 0 records.
|
||||
|
||||
---
|
||||
|
||||
BIN
migrations/versions/79972ec5f79d_er_diagram.png
Normal file
BIN
migrations/versions/79972ec5f79d_er_diagram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
|
|
@ -1,17 +1,20 @@
|
|||
"""init
|
||||
"""int
|
||||
|
||||
Revision ID: c8516c888495
|
||||
Revision ID: 79972ec5f79d
|
||||
Revises:
|
||||
Create Date: 2023-05-25 18:42:37.057225
|
||||
Create Date: 2023-06-22 15:02:20.292322
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
from learn_sql_model.er_diagram import generate_er_diagram, generate_er_markdown
|
||||
from learn_sql_model.config import get_config
|
||||
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c8516c888495'
|
||||
revision = '79972ec5f79d'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
|
@ -19,26 +22,25 @@ depends_on = None
|
|||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('pet',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('hero',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('secret_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('age', sa.Integer(), nullable=True),
|
||||
sa.Column('shoe_size', sa.Integer(), nullable=True),
|
||||
sa.Column('pet_id', sa.Integer(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['pet_id'], ['pet.id'], ),
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('pet',
|
||||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('birthday', sa.DateTime(), nullable=True),
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
generate_er_diagram(f'migrations/versions/{revision}_er_diagram.png')
|
||||
generate_er_markdown(f'migrations/versions/{revision}_er_diagram.md', f'migrations/versions/er_diagram_{revision}.png')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('hero')
|
||||
op.drop_table('pet')
|
||||
op.drop_table('hero')
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
"""add birthday
|
||||
|
||||
Revision ID: a9bb6625c57b
|
||||
Revises: c8516c888495
|
||||
Create Date: 2023-05-25 19:00:58.137464
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a9bb6625c57b'
|
||||
down_revision = 'c8516c888495'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('pet', sa.Column('birthday', sa.DateTime(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('pet', 'birthday')
|
||||
# ### end Alembic commands ###
|
||||
Loading…
Add table
Add a link
Reference in a new issue