Beispiel #1
0
    def _load_objects(self):
        self.classes = []
        self.models = []
        self.table_names = []

        _base = get_declarative_base()
        for clazz in list(_base._decl_class_registry.values()):  # pylint: disable=protected-access
            try:
                self.table_names.append(clazz.__tablename__)
                self.classes.append(clazz)
            except Exception:
                pass
        for table in _base.metadata.tables.items():
            if table[0] in self.table_names:
                clazz = self.classes[self.table_names.index(table[0])]
                name = clazz.__tablename__.lower()
                self.models.append(name)
                self.class_map[name] = clazz
Beispiel #2
0
 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.
"""
# pylint: disable=no-member,too-few-public-methods

import datetime

from sqlalchemy.orm import relationship, backref
from sqlalchemy import Column, String, ForeignKey, Integer, DateTime, Boolean, Text, Enum

from rapid.lib import get_declarative_base
from rapid.master.data.database.models.base.base_model import BaseModel
from rapid.lib.constants import VcsReleaseStepType
Base = get_declarative_base()


class Release(BaseModel, Base):
    name = Column(String(255), nullable=False, index=True)
    date_created = Column(DateTime(),
                          nullable=False,
                          default=datetime.datetime.utcnow,
                          index=True)
    status_id = Column(Integer,
                       ForeignKey('statuses.id'),
                       nullable=False,
                       index=True)
    commit_id = Column(Integer,
                       ForeignKey('commits.id'),
                       nullable=False,
Beispiel #3
0
# get the app
from rapid.lib import get_declarative_base

# 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)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = get_declarative_base().metadata
# exit(1)
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline():
    """Run migrations in 'offline' mode.
    This configures the context with just a URL
    and not an Engine, though an Engine is acceptable
    here as well.  By skipping the Engine creation
    we don't even need a DBAPI to be available.
    Calls to context.execute() here emit the given string to the
    script output.