diff --git a/CTFd/api/v1/config.py b/CTFd/api/v1/config.py index 9be0824c..ae1c686e 100644 --- a/CTFd/api/v1/config.py +++ b/CTFd/api/v1/config.py @@ -8,7 +8,7 @@ from CTFd.api.v1.helpers.schemas import sqlalchemy_to_pydantic from CTFd.api.v1.schemas import APIDetailedSuccessResponse, APIListSuccessResponse from CTFd.cache import clear_config, clear_standings from CTFd.constants import RawEnum -from CTFd.models import Fields, Configs, db +from CTFd.models import Configs, Fields, db from CTFd.schemas.config import ConfigSchema from CTFd.schemas.fields import FieldSchema from CTFd.utils import set_config diff --git a/migrations/versions/75e8ab9a0014_add_fields_and_fieldentries_tables.py b/migrations/versions/75e8ab9a0014_add_fields_and_fieldentries_tables.py new file mode 100644 index 00000000..4bef4cb6 --- /dev/null +++ b/migrations/versions/75e8ab9a0014_add_fields_and_fieldentries_tables.py @@ -0,0 +1,53 @@ +"""Add Fields and FieldEntries tables + +Revision ID: 75e8ab9a0014 +Revises: 0366ba6575ca +Create Date: 2020-08-19 00:36:17.579497 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "75e8ab9a0014" +down_revision = "0366ba6575ca" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "fields", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("name", sa.Text(), nullable=True), + sa.Column("type", sa.String(length=80), nullable=True), + sa.Column("field_type", sa.String(length=80), nullable=True), + sa.Column("description", sa.Text(), nullable=True), + sa.Column("required", sa.Boolean(), nullable=True), + sa.Column("public", sa.Boolean(), nullable=True), + sa.Column("editable", sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint("id"), + ) + op.create_table( + "field_entries", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("type", sa.String(length=80), nullable=True), + sa.Column("value", sa.JSON(), nullable=True), + sa.Column("field_id", sa.Integer(), nullable=True), + sa.Column("user_id", sa.Integer(), nullable=True), + sa.Column("team_id", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(["field_id"], ["fields.id"], ondelete="CASCADE"), + sa.ForeignKeyConstraint(["team_id"], ["teams.id"], ondelete="CASCADE"), + sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"), + sa.PrimaryKeyConstraint("id"), + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table("field_entries") + op.drop_table("fields") + # ### end Alembic commands ###