-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Create new databases from the ORM #24156
Conversation
This is not a prompt to change anything, merely an observation — it feels weird to create an instance of the webserver to init the DB. |
d0c517d
to
2a55cab
Compare
I have moved the creation of the session into the webserver. This means DB initialization would not create the session table but starting up the webserver would create the session table. This makes sense since the session table is from flask_session and not part of airflow. |
2a55cab
to
4822ec6
Compare
4822ec6
to
628f854
Compare
628f854
to
be4e317
Compare
204cf7e
to
df04aae
Compare
SQLite is failing with
|
00dcb3e
to
783a71e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the conditionals we need to have in initdb
it might be worth it if we re-factor it to be:
@provide_session
def initdb(session: Session = NEW_SESSION):
"""Initialize Airflow database."""
if db_exists:
_create_db_from_orm(session=session)
else:
upgradedb(session=session)
if conf.getboolean('database', 'LOAD_DEFAULT_CONNECTIONS'):
create_default_connections(session=session)
And that way upgradedb can call this new function.
3cef399
to
2001f90
Compare
2001f90
to
2ff1a47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally lgtm, just one small-ish thing
fixup! Create new db from the ORM fixup! fixup! Create new db from the ORM
Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
8394f18
to
e948a28
Compare
This PR opens up to creating new databases from the ORM instead of going through the migration files.
airflow db init
creates the new db.Depends on ##24044