# Path: deckhand/db/sqlalchemy/api.py
# LOG = logging.getLogger(__name__)
# CONF = cfg.CONF
# _FACADE = None
# _LOCK = threading.Lock()
#                 _FACADE = session.EngineFacade.from_config(
#                     CONF, sqlite_fk=True)
# def _create_facade_lazily():
# def get_engine():
# def get_session(autocommit=True, expire_on_commit=False):
# def drop_db():
# def setup_db(connection_string, create_tables=False):
# def raw_query(query, **kwargs):
# def require_unique_document_schema(schema=None):
#     def decorator(f):
#         def wrapper(bucket_name, documents, *args, **kwargs):
# def documents_create(bucket_name, documents, validations=None,
#                      session=None):
# def _documents_create(bucket_name, documents, session=None):
#     def _document_create(document):
# def _fill_in_metadata_defaults(document):
# def _make_hash(data):
# def document_get(session=None, raw_dict=False, revision_id=None, **filters):
# def document_get_all(session=None, raw_dict=False, revision_id=None,
#                      **filters):
# def bucket_get_or_create(bucket_name, session=None):
# def revision_create(session=None):
# def revision_get(revision_id=None, session=None):
# def revision_get_latest(session=None):
# def require_revision_exists(f):
#     def wrapper(revision_id=None, *args, **kwargs):
# def _update_revision_history(documents):
# def revision_get_all(session=None, **filters):
# def revision_delete_all():
# def _exclude_deleted_documents(documents):
# def _filter_revision_documents(documents, unique_only, **filters):
# def revision_documents_get(revision_id=None, include_history=True,
#                            unique_only=True, session=None, **filters):
# def revision_diff(revision_id, comparison_revision_id):
#     def _compare_buckets(b1, b2):
# def revision_tag_create(revision_id, tag, data=None, session=None):
# def revision_tag_get(revision_id, tag, session=None):
# def revision_tag_get_all(revision_id, session=None):
# def revision_tag_delete(revision_id, tag, session=None):
# def revision_tag_delete_all(revision_id, session=None):
# def revision_rollback(revision_id, latest_revision, session=None):
# def _get_validation_policies_for_revision(revision_id, session=None):
# def validation_create(revision_id, val_name, val_data, session=None):
# def validation_get_all(revision_id, session=None):
# def _check_validation_entries_against_validation_policies(
#         revision_id, entries, val_name=None, session=None):
# def validation_get_all_entries(revision_id, val_name=None, session=None):
# def validation_get_entry(revision_id, val_name, entry_id, session=None):
# 
# Path: deckhand/db/sqlalchemy/models.py
# LOG = logging.getLogger(__name__)
# BASE = None
#     BASE = declarative.declarative_base()
#         UNIQUE_CONSTRAINTS = ('schema', 'layer', 'name', 'revision_id')
# class DeckhandBase(models.ModelBase, models.TimestampMixin):
#     class Bucket(BASE, DeckhandBase):
#     class RevisionTag(BASE, DeckhandBase):
#     class Revision(BASE, DeckhandBase):
#     class Document(BASE, DeckhandBase):
#     class Validation(BASE, DeckhandBase):
#     def save(self, session=None):
#     def safe_delete(self, session=None):
#     def keys(self):
#     def values(self):
#     def items(self):
#     def to_dict(self):
# def __build_tables(blob_type_obj, blob_type_list):
#         def to_dict(self):
#         def bucket_name(self):
#         def to_dict(self, raw_dict=False):
# def register_models(engine, connection_string):
# def create_tables(engine):
# def unregister_models(engine):


import logging
import os
from logging.config import fileConfig
from alembic import context
from oslo_config import cfg
from sqlalchemy import engine_from_config, pool
from deckhand.db.sqlalchemy import api as db_api
from deckhand.db.sqlalchemy import models
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import with_statement



# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)


# Portions modified for Deckhand Specifics:
# Set up and retrieve the config file for Deckhand. Sets up the oslo_config
logger = logging.getLogger('alembic.env')
CONF = cfg.CONF
dirname = os.environ.get('DECKHAND_CONFIG_DIR', '/etc/deckhand').strip()
config_files = [os.path.join(dirname, 'deckhand.conf')]
CONF([], project='deckhand', default_config_files=config_files)
logger.info("Database Connection: %s", CONF.database.connection)
config.set_main_option('sqlalchemy.url', CONF.database.connection)
models.register_models(db_api.get_engine(),
                       CONF.database.connection)

# Path: deckhand/db/sqlalchemy/api.py
# LOG = logging.getLogger(__name__)
# CONF = cfg.CONF
# _FACADE = None
# _LOCK = threading.Lock()
#                 _FACADE = session.EngineFacade.from_config(
#                     CONF, sqlite_fk=True)
# def _create_facade_lazily():
# def get_engine():
# def get_session(autocommit=True, expire_on_commit=False):
# def drop_db():
# def setup_db(connection_string, create_tables=False):
# def raw_query(query, **kwargs):
# def require_unique_document_schema(schema=None):
#     def decorator(f):
#         def wrapper(bucket_name, documents, *args, **kwargs):
# def documents_create(bucket_name, documents, validations=None,
#                      session=None):
# def _documents_create(bucket_name, documents, session=None):
#     def _document_create(document):
# def _fill_in_metadata_defaults(document):
# def _make_hash(data):
# def document_get(session=None, raw_dict=False, revision_id=None, **filters):
# def document_get_all(session=None, raw_dict=False, revision_id=None,
#                      **filters):
# def bucket_get_or_create(bucket_name, session=None):
# def revision_create(session=None):
# def revision_get(revision_id=None, session=None):
# def revision_get_latest(session=None):
# def require_revision_exists(f):
#     def wrapper(revision_id=None, *args, **kwargs):
# def _update_revision_history(documents):
# def revision_get_all(session=None, **filters):
# def revision_delete_all():
# def _exclude_deleted_documents(documents):
# def _filter_revision_documents(documents, unique_only, **filters):
# def revision_documents_get(revision_id=None, include_history=True,
#                            unique_only=True, session=None, **filters):
# def revision_diff(revision_id, comparison_revision_id):
#     def _compare_buckets(b1, b2):
# def revision_tag_create(revision_id, tag, data=None, session=None):
# def revision_tag_get(revision_id, tag, session=None):
# def revision_tag_get_all(revision_id, session=None):
# def revision_tag_delete(revision_id, tag, session=None):
# def revision_tag_delete_all(revision_id, session=None):
# def revision_rollback(revision_id, latest_revision, session=None):
# def _get_validation_policies_for_revision(revision_id, session=None):
# def validation_create(revision_id, val_name, val_data, session=None):
# def validation_get_all(revision_id, session=None):
# def _check_validation_entries_against_validation_policies(
#         revision_id, entries, val_name=None, session=None):
# def validation_get_all_entries(revision_id, val_name=None, session=None):
# def validation_get_entry(revision_id, val_name, entry_id, session=None):
# 
# Path: deckhand/db/sqlalchemy/models.py
# LOG = logging.getLogger(__name__)
# BASE = None
#     BASE = declarative.declarative_base()
#         UNIQUE_CONSTRAINTS = ('schema', 'layer', 'name', 'revision_id')
# class DeckhandBase(models.ModelBase, models.TimestampMixin):
#     class Bucket(BASE, DeckhandBase):
#     class RevisionTag(BASE, DeckhandBase):
#     class Revision(BASE, DeckhandBase):
#     class Document(BASE, DeckhandBase):
#     class Validation(BASE, DeckhandBase):
#     def save(self, session=None):
#     def safe_delete(self, session=None):
#     def keys(self):
#     def values(self):
#     def items(self):
#     def to_dict(self):
# def __build_tables(blob_type_obj, blob_type_list):
#         def to_dict(self):
#         def bucket_name(self):
#         def to_dict(self, raw_dict=False):
# def register_models(engine, connection_string):
# def create_tables(engine):
# def unregister_models(engine):


# Path: alembic/env.py
import logging
import os
from logging.config import fileConfig
from alembic import context
from oslo_config import cfg
from sqlalchemy import engine_from_config, pool
from deckhand.db.sqlalchemy import api as db_api
from deckhand.db.sqlalchemy import models

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import with_statement



# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)


# Portions modified for Deckhand Specifics:
# Set up and retrieve the config file for Deckhand. Sets up the oslo_config
logger = logging.getLogger('alembic.env')
CONF = cfg.CONF
dirname = os.environ.get('DECKHAND_CONFIG_DIR', '/etc/deckhand').strip()
config_files = [os.path.join(dirname, 'deckhand.conf')]
CONF([], project='deckhand', default_config_files=config_files)
logger.info("Database Connection: %s", CONF.database.connection)
config.set_main_option('sqlalchemy.url', CONF.database.connection)
models.register_models(db_api.get_engine(),
                       CONF.database.connection)

target_metadata = models.BASE.metadata