airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (AIRFLOW-251) Add optional parameter SQL_ALCHEMY_SCHEMA to control schema for metadata repository
Date Mon, 03 Sep 2018 22:54:00 GMT


ASF GitHub Bot commented on AIRFLOW-251:

kaxil closed pull request #1600: [AIRFLOW-251] Add option SQL_ALCHEMY_SCHEMA parameter to
use SQL Server for metadata.

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/ b/airflow/
index e03b713046..03f15d721d 100644
--- a/airflow/
+++ b/airflow/
@@ -106,6 +106,7 @@ def run_command(command):
         'dags_are_paused_at_creation': True,
         'sql_alchemy_pool_size': 5,
         'sql_alchemy_pool_recycle': 3600,
+        'sql_alchemy_schema': None,
         'dagbag_import_timeout': 30,
         'non_pooled_task_slot_count': 128,
@@ -210,6 +211,10 @@ def run_command(command):
 # their website
 sql_alchemy_conn = sqlite:///{AIRFLOW_HOME}/airflow.db
+# The schema to use for the metadata database
+# SqlAlchemy supports databases with the concept of multiple schemas.
+sql_alchemy_schema =
 # The SqlAlchemy pool size is the maximum number of database connections
 # in the pool.
 sql_alchemy_pool_size = 5
diff --git a/airflow/ b/airflow/
index 1b613188ca..cf8adfa04f 100644
--- a/airflow/
+++ b/airflow/
@@ -47,7 +47,7 @@
 from sqlalchemy import (
     Column, Integer, String, DateTime, Text, Boolean, ForeignKey, PickleType,
     Index, Float)
-from sqlalchemy import case, func, or_, and_
+from sqlalchemy import case, func, or_, and_, MetaData
 from sqlalchemy.ext.declarative import declarative_base, declared_attr
 from sqlalchemy.dialects.mysql import LONGTEXT
 from sqlalchemy.orm import relationship, synonym
@@ -71,7 +71,11 @@
 from airflow.utils.timeout import timeout
 from airflow.utils.trigger_rule import TriggerRule
-Base = declarative_base()
+SQL_ALCHEMY_SCHEMA = configuration.get('core', 'SQL_ALCHEMY_SCHEMA')
+    Base = declarative_base()
+    Base = declarative_base(metadata=MetaData(schema=SQL_ALCHEMY_SCHEMA))
 ID_LEN = 250
 SQL_ALCHEMY_CONN = configuration.get('core', 'SQL_ALCHEMY_CONN')
 DAGS_FOLDER = os.path.expanduser(configuration.get('core', 'DAGS_FOLDER'))


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:

> Add optional parameter SQL_ALCHEMY_SCHEMA to control schema for metadata repository
> -----------------------------------------------------------------------------------
>                 Key: AIRFLOW-251
>                 URL:
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 2.0.0
>            Reporter: Ed Parcell
>            Priority: Minor
> Using SQL Server as a database for metadata, it is preferable to group all Airflow tables
into a separate schema, rather than using dbo. I propose adding an optional parameter SQL_ALCHEMY_SCHEMA
to control this.

This message was sent by Atlassian JIRA

View raw message