ashb closed pull request #4199: [AIRFLOW-251] Add option SQL_ALCHEMY_SCHEMA
parameter to use SQL Serv…
URL: https://github.com/apache/incubator-airflow/pull/4199
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/config_templates/default_airflow.cfg
b/airflow/config_templates/default_airflow.cfg
index 4d73fdf51d..a9473178c1 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -106,6 +106,10 @@ sql_alchemy_pool_recycle = 1800
# disconnects. Setting this to 0 disables retries.
sql_alchemy_reconnect_timeout = 300
+# The schema to use for the metadata database
+# SqlAlchemy supports databases with the concept of multiple schemas.
+sql_alchemy_schema =
+
# The amount of parallelism as a setting to the executor. This defines
# the max number of task instances that should run simultaneously
# on this airflow installation
diff --git a/airflow/models.py b/airflow/models.py
index 92440a81a9..bb068499fe 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -64,7 +64,7 @@
from sqlalchemy import (
Boolean, Column, DateTime, Float, ForeignKey, ForeignKeyConstraint, Index,
- Integer, LargeBinary, PickleType, String, Text, UniqueConstraint,
+ Integer, LargeBinary, PickleType, String, Text, UniqueConstraint, MetaData,
and_, asc, func, or_, true as sqltrue
)
from sqlalchemy.ext.declarative import declarative_base, declared_attr
@@ -108,7 +108,13 @@
install_aliases()
-Base = declarative_base()
+SQL_ALCHEMY_SCHEMA = configuration.get('core', 'SQL_ALCHEMY_SCHEMA')
+
+if not SQL_ALCHEMY_SCHEMA or SQL_ALCHEMY_SCHEMA.isspace():
+ Base = declarative_base()
+else:
+ Base = declarative_base(metadata=MetaData(schema=SQL_ALCHEMY_SCHEMA))
+
ID_LEN = 250
XCOM_RETURN_KEY = 'return_value'
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services