Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to update schema once created? #204

Open
8 tasks done
perfecto25 opened this issue Dec 27, 2021 · 1 comment
Open
8 tasks done

Is it possible to update schema once created? #204

perfecto25 opened this issue Dec 27, 2021 · 1 comment
Labels
question Further information is requested

Comments

@perfecto25
Copy link

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the SQLModel documentation, with the integrated search.
  • I already searched in Google "How to X in SQLModel" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to SQLModel but to Pydantic.
  • I already checked if it is not related to SQLModel but to SQLAlchemy.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

class Xconnect(SQLModel, table=True):
    id: int = Field(primary_key=True)
    lvc: Optional[str] = Field(sa_column_kwargs={"unique": True})
    customer: int = Field(foreign_key="customer.id")
    region: int = Field(foreign_key="attr.id")

Description

Im trying to see if I can update the exisitng generated table Xconnect without deleting and recreating it,

for example, if I wantto make the Region field Optional, adding

region: Optional[int]

will not update the existing schema bcs the table is already created. How can I update the existing schema? Do I need to use Alembic for this?

Operating System

Linux

Operating System Details

linux mint 19

SQLModel Version

0.0.5

Python Version

3.8

Additional Context

No response

@perfecto25 perfecto25 added the question Further information is requested label Dec 27, 2021
@voxofox
Copy link

voxofox commented Mar 30, 2022

As you've mentioned, Alembic would be a good solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants