import yaml
import logging


def _read_instructions() -> dict:
    """Read the database migration instructions. These are contained in the
    migrate.yaml file of the database project.

    Parameters
    ----------
    None

    Returns
    -------
    migrate : dict
        Database metadata and migration instructions

    Notes
    -----
    This function assumes that the current working directory is the root
    directory of the database project. If no migrate.yaml file is found, we
    throw an error.
    """
    try:
        stream = open('/deployment/migrate.yaml', 'r')
        migrate = yaml.safe_load(stream)
    except FileNotFoundError:
        logging.error('Database project must have migrate.yaml to be deployed.')
        raise FileNotFoundError

    return migrate