-
Notifications
You must be signed in to change notification settings - Fork 2
Implemented Popular Times, Authentication, and Messaging #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d733e34
8a3f4e0
7d5a438
9239f2f
4793aa8
cf67794
4fb2ca8
61a6433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| [alembic] | ||
| script_location = migrations | ||
|
|
||
| [loggers] | ||
| keys = root,alembic | ||
|
|
||
| [handlers] | ||
| keys = console | ||
|
|
||
| [formatters] | ||
| keys = generic | ||
|
|
||
| [logger_root] | ||
| level = DEBUG | ||
| handlers = console | ||
| qualname = | ||
|
|
||
| [handler_console] | ||
| class = StreamHandler | ||
| args = (sys.stderr,) | ||
| level = DEBUG | ||
| formatter = generic | ||
|
|
||
| [formatter_generic] | ||
| format = %(levelname)s: %(message)s |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to move scrape_classes out of the if statement? This will cause scrape_classes to run during migrations, which might cause an error because the migration is not complete before we run the scrape. |
This file was deleted.
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an explanation for changes to this file? I'm worried during deployment there will be a lot to debug due to the changes in migration code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,95 +1,58 @@ | ||
| from __future__ import with_statement | ||
| import sys | ||
| import os | ||
| from flask import current_app | ||
|
|
||
| import logging | ||
| from logging.config import fileConfig | ||
|
|
||
| from sqlalchemy import engine_from_config | ||
| from sqlalchemy import pool | ||
|
|
||
| from alembic import context | ||
| from sqlalchemy import engine_from_config, pool | ||
| from logging.config import fileConfig | ||
| import logging | ||
|
|
||
| # this is the Alembic Config object, which provides | ||
| # access to the values within the .ini file in use. | ||
| config = context.config | ||
| # This sets up logging with a fallback if the config is missing or incorrect | ||
| try: | ||
| fileConfig(context.config.config_file_name) | ||
| except KeyError: | ||
| logging.basicConfig(level=logging.INFO, format="%(levelname)-5.5s [%(name)s] %(message)s") | ||
|
|
||
| # Interpret the config file for Python logging. | ||
| # This line sets up loggers basically. | ||
| fileConfig(config.config_file_name) | ||
| logger = logging.getLogger('alembic.env') | ||
| print(f"Using Alembic config file: {context.config.config_file_name}") | ||
|
|
||
| # add your model's MetaData object here | ||
| # for 'autogenerate' support | ||
| # from myapp import mymodel | ||
| # target_metadata = mymodel.Base.metadata | ||
| config.set_main_option('sqlalchemy.url', | ||
| current_app.config.get('SQLALCHEMY_DATABASE_URI')) | ||
| target_metadata = current_app.extensions['migrate'].db.metadata | ||
|
|
||
| # 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. | ||
| # Add your project directory to the Python path | ||
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))) | ||
| from app import app | ||
|
|
||
| # Alembic Config object | ||
| config = context.config | ||
|
|
||
| def run_migrations_offline(): | ||
| """Run migrations in 'offline' mode. | ||
| # # Configure logging | ||
| # fileConfig(config.config_file_name) | ||
|
|
||
| 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. | ||
| # Set SQLAlchemy URL and metadata | ||
| with app.app_context(): | ||
| config.set_main_option('sqlalchemy.url', current_app.config['SQLALCHEMY_DATABASE_URI']) | ||
| target_metadata = current_app.extensions['migrate'].db.metadata | ||
|
|
||
| Calls to context.execute() here emit the given string to the | ||
| script output. | ||
|
|
||
| """ | ||
| def run_migrations_offline(): | ||
| """Run migrations in 'offline' mode.""" | ||
| url = config.get_main_option("sqlalchemy.url") | ||
| context.configure( | ||
| url=url, target_metadata=target_metadata, literal_binds=True | ||
| ) | ||
|
|
||
| context.configure(url=url, target_metadata=target_metadata, literal_binds=True) | ||
| with context.begin_transaction(): | ||
| context.run_migrations() | ||
|
|
||
|
|
||
| def run_migrations_online(): | ||
| """Run migrations in 'online' mode. | ||
|
|
||
| In this scenario we need to create an Engine | ||
| and associate a connection with the context. | ||
|
|
||
| """ | ||
|
|
||
| # this callback is used to prevent an auto-migration from being generated | ||
| # when there are no changes to the schema | ||
| # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html | ||
| def process_revision_directives(context, revision, directives): | ||
| if getattr(config.cmd_opts, 'autogenerate', False): | ||
| script = directives[0] | ||
| if script.upgrade_ops.is_empty(): | ||
| directives[:] = [] | ||
| logger.info('No changes in schema detected.') | ||
|
|
||
| """Run migrations in 'online' mode.""" | ||
| connectable = engine_from_config( | ||
| config.get_section(config.config_ini_section), | ||
| prefix='sqlalchemy.', | ||
| poolclass=pool.NullPool, | ||
| ) | ||
|
|
||
| with connectable.connect() as connection: | ||
| context.configure( | ||
| connection=connection, | ||
| target_metadata=target_metadata, | ||
| process_revision_directives=process_revision_directives, | ||
| **current_app.extensions['migrate'].configure_args | ||
| ) | ||
|
|
||
| context.configure(connection=connection, target_metadata=target_metadata) | ||
| with context.begin_transaction(): | ||
| context.run_migrations() | ||
|
|
||
|
|
||
| if context.is_offline_mode(): | ||
| run_migrations_offline() | ||
| else: | ||
| run_migrations_online() | ||
| run_migrations_online() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly does this file do? I think alembic has already been initialized, but maybe we were missing this file?