-
Notifications
You must be signed in to change notification settings - Fork 448
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
Dev: Add initial migration and Running migration instruction to README #1133
Open
mtreacy002
wants to merge
1
commit into
anitab-org:develop
Choose a base branch
from
mtreacy002:add-migration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
|
||
config.set_main_option( | ||
"sqlalchemy.url", | ||
current_app.config.get("SQLALCHEMY_DATABASE_URI").replace("%", "%%"), | ||
str(current_app.extensions["migrate"].db.engine.url).replace("%", "%%"), | ||
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. why this change @mtreacy002 ? just asking because at the moment this came to the project, I thought it was kind of auto-generated code 🤔 but i am not sure |
||
) | ||
target_metadata = current_app.extensions["migrate"].db.metadata | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
"""Initial migration | ||
|
||
Revision ID: 0541c68e5b13 | ||
Revises: | ||
Create Date: 2021-07-07 12:20:10.523552 | ||
|
||
""" | ||
from alembic import op | ||
from app.database.db_types.JsonCustomType import JsonCustomType | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "0541c68e5b13" | ||
down_revision = None | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"tasks_list", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("tasks", JsonCustomType, nullable=True), | ||
sa.Column("next_task_id", sa.Integer(), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"users", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sa.String(length=30), nullable=True), | ||
sa.Column("username", sa.String(length=30), nullable=True), | ||
sa.Column("email", sa.String(length=254), nullable=True), | ||
sa.Column("password_hash", sa.String(length=100), nullable=True), | ||
sa.Column("registration_date", sa.Float(), nullable=True), | ||
sa.Column("terms_and_conditions_checked", sa.Boolean(), nullable=True), | ||
sa.Column("is_admin", sa.Boolean(), nullable=True), | ||
sa.Column("is_email_verified", sa.Boolean(), nullable=True), | ||
sa.Column("email_verification_date", sa.DateTime(), nullable=True), | ||
sa.Column("current_mentorship_role", sa.Integer(), nullable=True), | ||
sa.Column("membership_status", sa.Integer(), nullable=True), | ||
sa.Column("bio", sa.String(length=500), nullable=True), | ||
sa.Column("location", sa.String(length=80), nullable=True), | ||
sa.Column("occupation", sa.String(length=80), nullable=True), | ||
sa.Column("organization", sa.String(length=80), nullable=True), | ||
sa.Column("slack_username", sa.String(length=80), nullable=True), | ||
sa.Column("social_media_links", sa.String(length=500), nullable=True), | ||
sa.Column("skills", sa.String(length=500), nullable=True), | ||
sa.Column("interests", sa.String(length=200), nullable=True), | ||
sa.Column("resume_url", sa.String(length=200), nullable=True), | ||
sa.Column("photo_url", sa.String(length=200), nullable=True), | ||
sa.Column("need_mentoring", sa.Boolean(), nullable=True), | ||
sa.Column("available_to_mentor", sa.Boolean(), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("email"), | ||
sa.UniqueConstraint("username"), | ||
) | ||
op.create_table( | ||
"mentorship_relations", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("mentor_id", sa.Integer(), nullable=True), | ||
sa.Column("mentee_id", sa.Integer(), nullable=True), | ||
sa.Column("action_user_id", sa.Integer(), nullable=False), | ||
sa.Column("creation_date", sa.Float(), nullable=False), | ||
sa.Column("accept_date", sa.Float(), nullable=True), | ||
sa.Column("start_date", sa.Float(), nullable=True), | ||
sa.Column("end_date", sa.Float(), nullable=True), | ||
sa.Column( | ||
"state", | ||
sa.Enum( | ||
"PENDING", | ||
"ACCEPTED", | ||
"REJECTED", | ||
"CANCELLED", | ||
"COMPLETED", | ||
name="mentorshiprelationstate", | ||
), | ||
nullable=False, | ||
), | ||
sa.Column("notes", sa.String(length=400), nullable=True), | ||
sa.Column("tasks_list_id", sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["mentee_id"], | ||
["users.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["mentor_id"], | ||
["users.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["tasks_list_id"], | ||
["tasks_list.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"tasks_comments", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("task_id", sa.Integer(), nullable=True), | ||
sa.Column("relation_id", sa.Integer(), nullable=True), | ||
sa.Column("creation_date", sa.Float(), nullable=False), | ||
sa.Column("modification_date", sa.Float(), nullable=True), | ||
sa.Column("comment", sa.String(length=400), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
["relation_id"], | ||
["mentorship_relations.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["task_id"], | ||
["tasks_list.id"], | ||
), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["users.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("tasks_comments") | ||
op.drop_table("mentorship_relations") | ||
op.drop_table("users") | ||
op.drop_table("tasks_list") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
careful with spaces between lines, not sure this will render the way you are thinking. I viewed the source and this number does not show up