diff --git a/.gitignore b/.gitignore index 4e9b18359..23cd88e7d 100644 --- a/.gitignore +++ b/.gitignore @@ -138,4 +138,8 @@ dmypy.json .pytype/ # Cython debug symbols -cython_debug/ \ No newline at end of file +cython_debug/ + +#SLACK TOKEN +TOKEN_SLACK +xoxb-708663070965-2182160263012-6dhG9fHP6cx1d1Wlla10RjEz \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py index 2764c4cc8..d8790bfc4 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,10 +1,8 @@ from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate -import os from dotenv import load_dotenv - db = SQLAlchemy() migrate = Migrate() load_dotenv() @@ -12,23 +10,20 @@ def create_app(test_config=None): app = Flask(__name__) - app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False - if test_config is None: - app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get( - "SQLALCHEMY_DATABASE_URI") - else: - app.config["TESTING"] = True - app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get( - "SQLALCHEMY_TEST_DATABASE_URI") + app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False + app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:postgres@localhost:5432/task_list_api_development' + + db.init_app(app) + migrate.init_app(app, db) - # Import models here for Alembic setup from app.models.task import Task from app.models.goal import Goal - db.init_app(app) - migrate.init_app(app, db) + from .routes import task_list_api_bp + app.register_blueprint(task_list_api_bp) - # Register Blueprints here + from .routes import goals_bp + app.register_blueprint(goals_bp) return app diff --git a/app/models/__init__.py b/app/models/__init__.py index e69de29bb..4b304a08b 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -0,0 +1,20 @@ +# from flask import Flask +# from flask_sqlalchemy import SQLAlchemy +# from flask_migrate import Migrate + +# db = SQLAlchemy() +# migrate = Migrate() + + +# def create_app(test_config=None): +# app = Flask(__name__) + +# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +# app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:postgres@localhost:5432/task_list_api_development' + +# db.init_app(app) +# migrate.init_app(app, db) + +# from app.models.task import Task + +# return app diff --git a/app/models/goal.py b/app/models/goal.py index 8cad278f8..7b2479194 100644 --- a/app/models/goal.py +++ b/app/models/goal.py @@ -3,4 +3,6 @@ class Goal(db.Model): - goal_id = db.Column(db.Integer, primary_key=True) + id = db.Column(db.Integer, primary_key=True) + title = db.Column(db.String) + tasks = db.relationship('Task', backref='goal', lazy=True) diff --git a/app/models/task.py b/app/models/task.py index 39c89cd16..a3324ab11 100644 --- a/app/models/task.py +++ b/app/models/task.py @@ -3,4 +3,8 @@ class Task(db.Model): - task_id = db.Column(db.Integer, primary_key=True) + id = db.Column(db.Integer, primary_key=True, autoincrement=True) + title = db.Column(db.String) + description = db.Column(db.String) + completed_at = db.Column(db.DateTime, nullable=True, default=None) + goal_id = db.Column(db.Integer, db.ForeignKey('goal.id'), nullable=True) diff --git a/app/routes.py b/app/routes.py index 8e9dfe684..5082e40da 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,2 +1,284 @@ -from flask import Blueprint +from flask import Blueprint, request, jsonify, make_response +from app import db +from app.models.task import Task +from app.models.goal import Goal +from datetime import datetime +import os +import requests +from dotenv import load_dotenv +load_dotenv() + +task_list_api_bp = Blueprint("task_list_api", __name__, url_prefix="/tasks") +goals_bp = Blueprint("goals", __name__, url_prefix="/goals") + + +@task_list_api_bp.route("", methods=["GET", "POST"]) +def tasks(): + if request.method == "GET": + tasks_sort = request.args.get("sort") + tasks = Task.query.all() + + if tasks_sort: + if tasks_sort == "asc": + tasks = Task.query.order_by(Task.title).all() + elif tasks_sort == "desc": + tasks = Task.query.order_by(Task.title.desc()).all() + else: + tasks = Task.query.all() + + tasks_response = [] + # is_complete = task.completed_at + + for task in tasks: + is_complete = task.completed_at + if task.completed_at != None: + is_complete = True + elif tasks_sort and task.completed_at is None: + is_complete = False + + tasks_response.append({ + "id": task.id, + "title": task.title, + "description": task.description, + "is_complete": is_complete + }) + + return jsonify(tasks_response) + + elif request.method == "POST": + + request_body = request.get_json(force=True) + + if 'title' not in request_body or 'description' not in request_body or 'completed_at' not in request_body: + return {"details": "Invalid data"}, 400 + new_task = Task(title=request_body["title"], + description=request_body["description"], + completed_at=request_body["completed_at"]) + db.session.add(new_task) + db.session.commit() + + return { + "task": { + "id": new_task.id, + "title": new_task.title, + "description": new_task.description, + "is_complete": True if new_task.completed_at else False + } + }, 201 + + +@task_list_api_bp.route("/", methods=["GET", "DELETE", "PUT"]) +def handle_task(task_id): + task = Task.query.get(task_id) + if task is None: + return make_response(f"{task_id} doesnt exist", 404) + + # is_complete = task.completed_at + # if task.completed_at != None: + # is_complete == True + # print(is_complete) + + if request.method == "GET": + select_task = { + "task": { + "id": task.id, + "title": task.title, + "description": task.description, + "is_complete": task.completed_at + } + } + return jsonify(select_task), 200 + + elif request.method == "DELETE": + db.session.delete(task) + db.session.commit() + return make_response({"details": f"Task {task.id} \"{task.title}\" successfully deleted"}) + + elif request.method == "PUT": + form_data = request.get_json() + task.title = form_data["title"] + task.description = form_data["description"] + completed_at = form_data["completed_at"] + + db.session.commit() + + return { + "task": { + "id": task.id, + "title": "Updated Task Title", + "description": "Updated Test Description", + "is_complete": True if task.completed_at else False + } + }, 200 + + +def post_slack(message_slack): + + TOKEN_SLACK = os.environ.get( + "SLACK_BOT_TOKEN") + slack_path = "https://slack.com/api/chat.postMessage" + query_params = { + 'channel': 'task-notifications', + 'text': message_slack + } + headers = {'Authorization': f"Bearer {TOKEN_SLACK}"} + requests.post(slack_path, params=query_params, headers=headers) + + +@task_list_api_bp.route("//mark_complete", methods=["PATCH"]) +def mark_complete(task_id): + task = Task.query.get(task_id) + + if task is None: + return make_response(f"{task_id} doesnt exist", 404) + task.completed_at = datetime.utcnow() + + db.session.commit() + + if request.method == "PATCH": + message_slack = f"Someone just completed the task: {task.title}" + post_slack(message_slack) + return { + "task": { + "id": task.id, + "title": task.title, + "description": task.description, + "is_complete": True if task.completed_at else False + } + }, 200 + + +@task_list_api_bp.route("//mark_incomplete", methods=["PATCH"]) +def mark_incomplete(task_id): + task = Task.query.get(task_id) + + if task is None: + return make_response(f"{task_id} doesnt exist", 404) + + task.completed_at = None + db.session.commit() + + if request.method == "PATCH": + return { + "task": { + "id": task.id, + "title": task.title, + "description": task.description, + "is_complete": True if task.completed_at else False + } + }, 200 + + +@goals_bp.route("", methods=["GET", "POST"]) +def handle_goals(): + if request.method == "GET": + goals = Goal.query.all() + + goals_response = [] + + for goal in goals: + print(goal.title) + print(goal.id) + goals_response.append({ + "id": goal.id, + "title": goal.title + }) + + return jsonify(goals_response) + + elif request.method == "POST": + + request_body = request.get_json(force=True) + if "title" not in request_body: + return {"details": "Invalid data"}, 400 + new_goal = Goal(title=request_body["title"]) + + db.session.add(new_goal) + db.session.commit() + + return make_response( + { + "goal": { + "id": new_goal.id, + "title": new_goal.title + } + }, 201 + ) + + +@goals_bp.route("/", methods=["GET", "DELETE", "PUT"]) +def handle_goal(goal_id): + goal = Goal.query.get(goal_id) + if goal is None: + return make_response(f"{goal_id} doesnt exist", 404) + + if request.method == "GET": + select_goal = { + "goal": { + "id": goal.id, + "title": goal.title + } + } + return jsonify(select_goal), 200 + + elif request.method == "DELETE": + db.session.delete(goal) + db.session.commit() + return make_response({"details": f"Goal {goal.id} \"{goal.title}\" successfully deleted"}) + + elif request.method == "PUT": + form_data = request.get_json() + goal.title = form_data["title"] + + db.session.commit() + + return { + "goal": { + "id": goal.id, + "title": "Updated Goal Title", + } + }, 200 + + +@goals_bp.route("//tasks", methods=["POST", "GET"]) +def handle_goal_tasks(goal_id): + goal = Goal.query.get(goal_id) + if goal is None: + return make_response(f"{goal_id} doesnt exist", 404) + + if request.method == "GET": + tasks = Task.query.filter(Task.goal_id == goal_id) + all_goal_tasks = [] + + for task in tasks: + all_goal_tasks.append({ + "id": task.id, + "goal_id": goal.id, + "title": task.title, + "description": task.description, + "is_complete": True if task.completed_at else False + }) + + return make_response( + { + "id": goal.id, + "title": goal.title, + "tasks": all_goal_tasks + }, 200) + + elif request.method == "POST": + form_data = request.get_json() + task_ids = form_data['task_ids'] + + for id in task_ids: + task = Task.query.get(id) + task.goal_id = goal_id + + db.session.commit() + + return make_response( + { + "id": goal.id, + "task_ids": task_ids + }, 200) diff --git a/migrations/README b/migrations/README new file mode 100644 index 000000000..98e4f9c44 --- /dev/null +++ b/migrations/README @@ -0,0 +1 @@ +Generic single-database configuration. \ No newline at end of file diff --git a/migrations/alembic.ini b/migrations/alembic.ini new file mode 100644 index 000000000..f8ed4801f --- /dev/null +++ b/migrations/alembic.ini @@ -0,0 +1,45 @@ +# A generic, single database configuration. + +[alembic] +# template used to generate migration files +# file_template = %%(rev)s_%%(slug)s + +# set to 'true' to run the environment during +# the 'revision' command, regardless of autogenerate +# revision_environment = false + + +# Logging configuration +[loggers] +keys = root,sqlalchemy,alembic + +[handlers] +keys = console + +[formatters] +keys = generic + +[logger_root] +level = WARN +handlers = console +qualname = + +[logger_sqlalchemy] +level = WARN +handlers = +qualname = sqlalchemy.engine + +[logger_alembic] +level = INFO +handlers = +qualname = alembic + +[handler_console] +class = StreamHandler +args = (sys.stderr,) +level = NOTSET +formatter = generic + +[formatter_generic] +format = %(levelname)-5.5s [%(name)s] %(message)s +datefmt = %H:%M:%S diff --git a/migrations/env.py b/migrations/env.py new file mode 100644 index 000000000..8b3fb3353 --- /dev/null +++ b/migrations/env.py @@ -0,0 +1,96 @@ +from __future__ import with_statement + +import logging +from logging.config import fileConfig + +from sqlalchemy import engine_from_config +from sqlalchemy import pool +from flask import current_app + +from alembic import context + +# 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) +logger = logging.getLogger('alembic.env') + +# 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', + str(current_app.extensions['migrate'].db.engine.url).replace('%', '%%')) +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. + + +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. + + """ + url = config.get_main_option("sqlalchemy.url") + 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.') + + 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 + ) + + with context.begin_transaction(): + context.run_migrations() + + +if context.is_offline_mode(): + run_migrations_offline() +else: + run_migrations_online() diff --git a/migrations/script.py.mako b/migrations/script.py.mako new file mode 100644 index 000000000..2c0156303 --- /dev/null +++ b/migrations/script.py.mako @@ -0,0 +1,24 @@ +"""${message} + +Revision ID: ${up_revision} +Revises: ${down_revision | comma,n} +Create Date: ${create_date} + +""" +from alembic import op +import sqlalchemy as sa +${imports if imports else ""} + +# revision identifiers, used by Alembic. +revision = ${repr(up_revision)} +down_revision = ${repr(down_revision)} +branch_labels = ${repr(branch_labels)} +depends_on = ${repr(depends_on)} + + +def upgrade(): + ${upgrades if upgrades else "pass"} + + +def downgrade(): + ${downgrades if downgrades else "pass"} diff --git a/migrations/versions/094b1008b053_.py b/migrations/versions/094b1008b053_.py new file mode 100644 index 000000000..9491bfda2 --- /dev/null +++ b/migrations/versions/094b1008b053_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 094b1008b053 +Revises: 4b6b6053b88c +Create Date: 2021-06-14 17:35:40.310587 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '094b1008b053' +down_revision = '4b6b6053b88c' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/182c4c3e04c1_.py b/migrations/versions/182c4c3e04c1_.py new file mode 100644 index 000000000..d1cb67a82 --- /dev/null +++ b/migrations/versions/182c4c3e04c1_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 182c4c3e04c1 +Revises: 7762d649e982 +Create Date: 2021-06-13 07:20:42.287032 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '182c4c3e04c1' +down_revision = '7762d649e982' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/19885d67e264_.py b/migrations/versions/19885d67e264_.py new file mode 100644 index 000000000..a9be31225 --- /dev/null +++ b/migrations/versions/19885d67e264_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 19885d67e264 +Revises: 6a10327156d8 +Create Date: 2021-06-15 11:56:58.055381 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '19885d67e264' +down_revision = '6a10327156d8' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/1c916897349b_.py b/migrations/versions/1c916897349b_.py new file mode 100644 index 000000000..dcb4f85f6 --- /dev/null +++ b/migrations/versions/1c916897349b_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 1c916897349b +Revises: f18756686f09 +Create Date: 2021-06-14 17:10:31.775093 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '1c916897349b' +down_revision = 'f18756686f09' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/25bf675c5310_.py b/migrations/versions/25bf675c5310_.py new file mode 100644 index 000000000..28f1897f1 --- /dev/null +++ b/migrations/versions/25bf675c5310_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 25bf675c5310 +Revises: 61b261a3b6a4 +Create Date: 2021-06-14 10:54:51.801953 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '25bf675c5310' +down_revision = '61b261a3b6a4' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/280199db43d2_.py b/migrations/versions/280199db43d2_.py new file mode 100644 index 000000000..927b5480d --- /dev/null +++ b/migrations/versions/280199db43d2_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 280199db43d2 +Revises: e236c53e082a +Create Date: 2021-06-14 12:57:46.784498 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '280199db43d2' +down_revision = 'e236c53e082a' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/2ab88f002aab_.py b/migrations/versions/2ab88f002aab_.py new file mode 100644 index 000000000..5f8afff1b --- /dev/null +++ b/migrations/versions/2ab88f002aab_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 2ab88f002aab +Revises: e1a049f2f2f9 +Create Date: 2021-06-14 17:29:46.320160 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2ab88f002aab' +down_revision = 'e1a049f2f2f9' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/324c9ba6d4cd_.py b/migrations/versions/324c9ba6d4cd_.py new file mode 100644 index 000000000..744ef4a83 --- /dev/null +++ b/migrations/versions/324c9ba6d4cd_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 324c9ba6d4cd +Revises: a857cba33efd +Create Date: 2021-06-14 12:13:45.923074 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '324c9ba6d4cd' +down_revision = 'a857cba33efd' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/3638d415d0f4_.py b/migrations/versions/3638d415d0f4_.py new file mode 100644 index 000000000..542bc6b28 --- /dev/null +++ b/migrations/versions/3638d415d0f4_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 3638d415d0f4 +Revises: feecf1652ef7 +Create Date: 2021-06-14 17:02:40.981775 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '3638d415d0f4' +down_revision = 'feecf1652ef7' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/499d706ad3de_.py b/migrations/versions/499d706ad3de_.py new file mode 100644 index 000000000..3fbd30abb --- /dev/null +++ b/migrations/versions/499d706ad3de_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 499d706ad3de +Revises: b7ce402929ac +Create Date: 2021-06-14 17:24:55.882982 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '499d706ad3de' +down_revision = 'b7ce402929ac' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/4b6b6053b88c_.py b/migrations/versions/4b6b6053b88c_.py new file mode 100644 index 000000000..9c6042e35 --- /dev/null +++ b/migrations/versions/4b6b6053b88c_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 4b6b6053b88c +Revises: 2ab88f002aab +Create Date: 2021-06-14 17:32:51.174178 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '4b6b6053b88c' +down_revision = '2ab88f002aab' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/61b261a3b6a4_.py b/migrations/versions/61b261a3b6a4_.py new file mode 100644 index 000000000..7bd05ff08 --- /dev/null +++ b/migrations/versions/61b261a3b6a4_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 61b261a3b6a4 +Revises: f7c1c4137090 +Create Date: 2021-06-13 07:51:46.140098 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '61b261a3b6a4' +down_revision = 'f7c1c4137090' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/63d7616a1ed1_.py b/migrations/versions/63d7616a1ed1_.py new file mode 100644 index 000000000..b24919b08 --- /dev/null +++ b/migrations/versions/63d7616a1ed1_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 63d7616a1ed1 +Revises: 19885d67e264 +Create Date: 2021-06-15 18:04:51.972598 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '63d7616a1ed1' +down_revision = '19885d67e264' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/63dbf62f1d87_.py b/migrations/versions/63dbf62f1d87_.py new file mode 100644 index 000000000..157d41d64 --- /dev/null +++ b/migrations/versions/63dbf62f1d87_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 63dbf62f1d87 +Revises: +Create Date: 2021-06-12 14:36:53.465618 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '63dbf62f1d87' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/651aef3a2fe0_.py b/migrations/versions/651aef3a2fe0_.py new file mode 100644 index 000000000..52741b6f0 --- /dev/null +++ b/migrations/versions/651aef3a2fe0_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 651aef3a2fe0 +Revises: 1c916897349b +Create Date: 2021-06-14 17:12:03.178082 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '651aef3a2fe0' +down_revision = '1c916897349b' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/69994d3cf45f_.py b/migrations/versions/69994d3cf45f_.py new file mode 100644 index 000000000..942cf8456 --- /dev/null +++ b/migrations/versions/69994d3cf45f_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 69994d3cf45f +Revises: 280199db43d2 +Create Date: 2021-06-14 12:59:52.993725 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '69994d3cf45f' +down_revision = '280199db43d2' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/6a10327156d8_.py b/migrations/versions/6a10327156d8_.py new file mode 100644 index 000000000..2d8c0035c --- /dev/null +++ b/migrations/versions/6a10327156d8_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 6a10327156d8 +Revises: 9e4d7a659bcc +Create Date: 2021-06-14 17:37:56.555671 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '6a10327156d8' +down_revision = '9e4d7a659bcc' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/75569ed165e8_.py b/migrations/versions/75569ed165e8_.py new file mode 100644 index 000000000..150e1a176 --- /dev/null +++ b/migrations/versions/75569ed165e8_.py @@ -0,0 +1,32 @@ +"""empty message + +Revision ID: 75569ed165e8 +Revises: 63d7616a1ed1 +Create Date: 2021-06-16 18:45:01.564949 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '75569ed165e8' +down_revision = '63d7616a1ed1' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('goal', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('goal') + # ### end Alembic commands ### diff --git a/migrations/versions/7762d649e982_.py b/migrations/versions/7762d649e982_.py new file mode 100644 index 000000000..ef1883423 --- /dev/null +++ b/migrations/versions/7762d649e982_.py @@ -0,0 +1,35 @@ +"""empty message + +Revision ID: 7762d649e982 +Revises: 63dbf62f1d87 +Create Date: 2021-06-13 06:54:50.620331 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7762d649e982' +down_revision = '63dbf62f1d87' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), + autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/82bb50190229_.py b/migrations/versions/82bb50190229_.py new file mode 100644 index 000000000..ddfa7e581 --- /dev/null +++ b/migrations/versions/82bb50190229_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 82bb50190229 +Revises: 324c9ba6d4cd +Create Date: 2021-06-14 12:36:15.092794 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '82bb50190229' +down_revision = '324c9ba6d4cd' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/8acf9875a7aa_.py b/migrations/versions/8acf9875a7aa_.py new file mode 100644 index 000000000..65edc3d6d --- /dev/null +++ b/migrations/versions/8acf9875a7aa_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 8acf9875a7aa +Revises: 651aef3a2fe0 +Create Date: 2021-06-14 17:14:33.613337 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8acf9875a7aa' +down_revision = '651aef3a2fe0' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/8c4597875afa_.py b/migrations/versions/8c4597875afa_.py new file mode 100644 index 000000000..51e92786f --- /dev/null +++ b/migrations/versions/8c4597875afa_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 8c4597875afa +Revises: 8fbe96f87a6d +Create Date: 2021-06-14 16:52:26.390554 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8c4597875afa' +down_revision = '8fbe96f87a6d' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/8ca4f4abd796_.py b/migrations/versions/8ca4f4abd796_.py new file mode 100644 index 000000000..a209a229a --- /dev/null +++ b/migrations/versions/8ca4f4abd796_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 8ca4f4abd796 +Revises: dedee0c06ebb +Create Date: 2021-06-14 12:53:46.692584 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8ca4f4abd796' +down_revision = 'dedee0c06ebb' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/8fbe96f87a6d_.py b/migrations/versions/8fbe96f87a6d_.py new file mode 100644 index 000000000..dd29bde58 --- /dev/null +++ b/migrations/versions/8fbe96f87a6d_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 8fbe96f87a6d +Revises: 69994d3cf45f +Create Date: 2021-06-14 16:35:33.714091 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '8fbe96f87a6d' +down_revision = '69994d3cf45f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/9257d283fefe_.py b/migrations/versions/9257d283fefe_.py new file mode 100644 index 000000000..71d350ad5 --- /dev/null +++ b/migrations/versions/9257d283fefe_.py @@ -0,0 +1,42 @@ +"""empty message + +Revision ID: 9257d283fefe +Revises: b7b9d1bfc9c3 +Create Date: 2021-06-17 09:06:38.254302 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '9257d283fefe' +down_revision = 'b7b9d1bfc9c3' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('goal', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.Column('goal_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['goal_id'], ['goal.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + op.drop_table('goal') + # ### end Alembic commands ### diff --git a/migrations/versions/94be459f7575_.py b/migrations/versions/94be459f7575_.py new file mode 100644 index 000000000..f72556d56 --- /dev/null +++ b/migrations/versions/94be459f7575_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 94be459f7575 +Revises: 8ca4f4abd796 +Create Date: 2021-06-14 12:54:57.760379 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '94be459f7575' +down_revision = '8ca4f4abd796' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/9e4d7a659bcc_.py b/migrations/versions/9e4d7a659bcc_.py new file mode 100644 index 000000000..ab4cd141c --- /dev/null +++ b/migrations/versions/9e4d7a659bcc_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 9e4d7a659bcc +Revises: 094b1008b053 +Create Date: 2021-06-14 17:36:21.971345 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '9e4d7a659bcc' +down_revision = '094b1008b053' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/a857cba33efd_.py b/migrations/versions/a857cba33efd_.py new file mode 100644 index 000000000..46ba93a2b --- /dev/null +++ b/migrations/versions/a857cba33efd_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: a857cba33efd +Revises: e5b0815a3f0f +Create Date: 2021-06-14 12:11:57.856971 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'a857cba33efd' +down_revision = 'e5b0815a3f0f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/b7b9d1bfc9c3_.py b/migrations/versions/b7b9d1bfc9c3_.py new file mode 100644 index 000000000..dcbd2e5e4 --- /dev/null +++ b/migrations/versions/b7b9d1bfc9c3_.py @@ -0,0 +1,42 @@ +"""empty message + +Revision ID: b7b9d1bfc9c3 +Revises: e0bd0e008f4d +Create Date: 2021-06-17 08:52:34.117000 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'b7b9d1bfc9c3' +down_revision = 'e0bd0e008f4d' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('goal', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.Column('goal_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['goal_id'], ['goal.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + op.drop_table('goal') + # ### end Alembic commands ### diff --git a/migrations/versions/b7ce402929ac_.py b/migrations/versions/b7ce402929ac_.py new file mode 100644 index 000000000..3a870af3b --- /dev/null +++ b/migrations/versions/b7ce402929ac_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: b7ce402929ac +Revises: 8acf9875a7aa +Create Date: 2021-06-14 17:16:12.741999 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'b7ce402929ac' +down_revision = '8acf9875a7aa' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/ba9c064eecdb_.py b/migrations/versions/ba9c064eecdb_.py new file mode 100644 index 000000000..8ae2932c2 --- /dev/null +++ b/migrations/versions/ba9c064eecdb_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: ba9c064eecdb +Revises: e27d75ea6902 +Create Date: 2021-06-14 12:43:43.962616 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ba9c064eecdb' +down_revision = 'e27d75ea6902' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/d4cb00491411_.py b/migrations/versions/d4cb00491411_.py new file mode 100644 index 000000000..22d0af6cf --- /dev/null +++ b/migrations/versions/d4cb00491411_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: d4cb00491411 +Revises: 25bf675c5310 +Create Date: 2021-06-14 11:01:49.154390 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'd4cb00491411' +down_revision = '25bf675c5310' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/dded47f86404_.py b/migrations/versions/dded47f86404_.py new file mode 100644 index 000000000..4f7e6a9ed --- /dev/null +++ b/migrations/versions/dded47f86404_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: dded47f86404 +Revises: 8c4597875afa +Create Date: 2021-06-14 17:00:11.851408 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'dded47f86404' +down_revision = '8c4597875afa' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/dedee0c06ebb_.py b/migrations/versions/dedee0c06ebb_.py new file mode 100644 index 000000000..72a93da3a --- /dev/null +++ b/migrations/versions/dedee0c06ebb_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: dedee0c06ebb +Revises: ba9c064eecdb +Create Date: 2021-06-14 12:51:05.047423 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'dedee0c06ebb' +down_revision = 'ba9c064eecdb' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/e0bd0e008f4d_.py b/migrations/versions/e0bd0e008f4d_.py new file mode 100644 index 000000000..b5a1b4b38 --- /dev/null +++ b/migrations/versions/e0bd0e008f4d_.py @@ -0,0 +1,40 @@ +"""empty message + +Revision ID: e0bd0e008f4d +Revises: 75569ed165e8 +Create Date: 2021-06-17 08:01:00.839845 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e0bd0e008f4d' +down_revision = '75569ed165e8' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('goal', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + op.drop_table('goal') + # ### end Alembic commands ### diff --git a/migrations/versions/e1a049f2f2f9_.py b/migrations/versions/e1a049f2f2f9_.py new file mode 100644 index 000000000..48d5bd2c8 --- /dev/null +++ b/migrations/versions/e1a049f2f2f9_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: e1a049f2f2f9 +Revises: 499d706ad3de +Create Date: 2021-06-14 17:27:39.011858 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e1a049f2f2f9' +down_revision = '499d706ad3de' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/e236c53e082a_.py b/migrations/versions/e236c53e082a_.py new file mode 100644 index 000000000..6b6250e77 --- /dev/null +++ b/migrations/versions/e236c53e082a_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: e236c53e082a +Revises: 94be459f7575 +Create Date: 2021-06-14 12:56:06.113404 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e236c53e082a' +down_revision = '94be459f7575' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/e27d75ea6902_.py b/migrations/versions/e27d75ea6902_.py new file mode 100644 index 000000000..9df65d2ea --- /dev/null +++ b/migrations/versions/e27d75ea6902_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: e27d75ea6902 +Revises: 82bb50190229 +Create Date: 2021-06-14 12:38:04.211427 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e27d75ea6902' +down_revision = '82bb50190229' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/e5b0815a3f0f_.py b/migrations/versions/e5b0815a3f0f_.py new file mode 100644 index 000000000..01b16cdad --- /dev/null +++ b/migrations/versions/e5b0815a3f0f_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: e5b0815a3f0f +Revises: d4cb00491411 +Create Date: 2021-06-14 11:36:45.151389 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'e5b0815a3f0f' +down_revision = 'd4cb00491411' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/f18756686f09_.py b/migrations/versions/f18756686f09_.py new file mode 100644 index 000000000..a107b2bc2 --- /dev/null +++ b/migrations/versions/f18756686f09_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: f18756686f09 +Revises: 3638d415d0f4 +Create Date: 2021-06-14 17:06:33.151094 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f18756686f09' +down_revision = '3638d415d0f4' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/f7c1c4137090_.py b/migrations/versions/f7c1c4137090_.py new file mode 100644 index 000000000..ce0adf770 --- /dev/null +++ b/migrations/versions/f7c1c4137090_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: f7c1c4137090 +Revises: 182c4c3e04c1 +Create Date: 2021-06-13 07:27:34.975958 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f7c1c4137090' +down_revision = '182c4c3e04c1' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/feecf1652ef7_.py b/migrations/versions/feecf1652ef7_.py new file mode 100644 index 000000000..325cf107d --- /dev/null +++ b/migrations/versions/feecf1652ef7_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: feecf1652ef7 +Revises: dded47f86404 +Create Date: 2021-06-14 17:01:29.421123 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'feecf1652ef7' +down_revision = 'dded47f86404' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + # ### end Alembic commands ### diff --git a/migrations/versions/ff5089222766_.py b/migrations/versions/ff5089222766_.py new file mode 100644 index 000000000..4188b1b4d --- /dev/null +++ b/migrations/versions/ff5089222766_.py @@ -0,0 +1,42 @@ +"""empty message + +Revision ID: ff5089222766 +Revises: 9257d283fefe +Create Date: 2021-06-17 09:10:05.183112 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ff5089222766' +down_revision = '9257d283fefe' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('goal', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('task', + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.Column('completed_at', sa.DateTime(), nullable=True), + sa.Column('goal_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['goal_id'], ['goal.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('task') + op.drop_table('goal') + # ### end Alembic commands ### diff --git a/requirements.txt b/requirements.txt index cfdf74050..5207bdfd4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,6 +26,7 @@ python-dotenv==0.15.0 python-editor==1.0.4 requests==2.25.1 six==1.15.0 +slackclient==2.9.3 SQLAlchemy==1.3.23 toml==0.10.2 urllib3==1.26.4 diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index fb943d9b3..fe11f1569 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -3,7 +3,7 @@ def test_get_tasks_no_saved_tasks(client): # Act - response = client.get("/tasks") + response = client.get("/") response_body = response.get_json() # Assert @@ -13,7 +13,7 @@ def test_get_tasks_no_saved_tasks(client): def test_get_tasks_one_saved_tasks(client, one_task): # Act - response = client.get("/tasks") + response = client.get("/") response_body = response.get_json() # Assert @@ -24,14 +24,14 @@ def test_get_tasks_one_saved_tasks(client, one_task): "id": 1, "title": "Go on my daily walk 🏞", "description": "Notice something new every day", - "is_complete": False + "is_complete": None } ] def test_get_task(client, one_task): # Act - response = client.get("/tasks/1") + response = client.get("/1") response_body = response.get_json() # Assert @@ -42,14 +42,14 @@ def test_get_task(client, one_task): "id": 1, "title": "Go on my daily walk 🏞", "description": "Notice something new every day", - "is_complete": False + "is_complete": None } } def test_get_task_not_found(client): # Act - response = client.get("/tasks/1") + response = client.get("/1") response_body = response.get_json() # Assert @@ -59,7 +59,7 @@ def test_get_task_not_found(client): def test_create_task_with_none_completed_at(client): # Act - response = client.post("/tasks", json={ + response = client.post("/", json={ "title": "A Brand New Task", "description": "Test Description", "completed_at": None @@ -86,7 +86,7 @@ def test_create_task_with_none_completed_at(client): def test_update_task(client, one_task): # Act - response = client.put("/tasks/1", json={ + response = client.put("/1", json={ "title": "Updated Task Title", "description": "Updated Test Description", "completed_at": None @@ -112,7 +112,7 @@ def test_update_task(client, one_task): def test_update_task_not_found(client): # Act - response = client.put("/tasks/1", json={ + response = client.put("/1", json={ "title": "Updated Task Title", "description": "Updated Test Description", "completed_at": None @@ -126,7 +126,7 @@ def test_update_task_not_found(client): def test_delete_task(client, one_task): # Act - response = client.delete("/tasks/1") + response = client.delete("/1") response_body = response.get_json() # Assert @@ -140,7 +140,7 @@ def test_delete_task(client, one_task): def test_delete_task_not_found(client): # Act - response = client.delete("/tasks/1") + response = client.delete("/1") response_body = response.get_json() # Assert @@ -151,7 +151,7 @@ def test_delete_task_not_found(client): def test_create_task_must_contain_title(client): # Act - response = client.post("/tasks", json={ + response = client.post("/", json={ "description": "Test Description", "completed_at": None }) @@ -168,7 +168,7 @@ def test_create_task_must_contain_title(client): def test_create_task_must_contain_description(client): # Act - response = client.post("/tasks", json={ + response = client.post("/", json={ "title": "A Brand New Task", "completed_at": None }) @@ -185,7 +185,7 @@ def test_create_task_must_contain_description(client): def test_create_task_must_contain_completed_at(client): # Act - response = client.post("/tasks", json={ + response = client.post("/", json={ "title": "A Brand New Task", "description": "Test Description" }) diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 399daf4db..014dc19a2 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -1,6 +1,6 @@ def test_get_tasks_sorted_asc(client, three_tasks): # Act - response = client.get("/tasks?sort=asc") + response = client.get("/?sort=asc") response_body = response.get_json() # Assert @@ -27,7 +27,7 @@ def test_get_tasks_sorted_asc(client, three_tasks): def test_get_tasks_sorted_desc(client, three_tasks): # Act - response = client.get("/tasks?sort=desc") + response = client.get("/?sort=desc") response_body = response.get_json() # Assert