Nam's

Flask Study 02 - DB Migration 본문

개발/Back-end

Flask Study 02 - DB Migration

namespace 2021. 1. 26. 00:15

참고자료:
Alembric: alembic.sqlalchemy.org/en/latest/,     bitbucket.org/zzzeek/alembic/src/master/
Flask-Migrate: flask-migrate.readthedocs.io/

DB Migration이란?

[공부하고 더 채우기]

사용법 - wikidocs.net/81059

flask db init

flask db stamp head
# To set the revision in the database to the head, without performing any migrations. You can change head to the required change you want.
flask db migrate
# To detect automatically all the changes.
flask db upgrade
# To apply all the changes.

 

2021.02.07 내용 추가

flask db migrate 시 자꾸

INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

이 두줄만 뜨고 change를 detect하지 못하는 문제가 발생했다.
원인은 개발 중 프로젝트에 문제가 생겨 git repository에서 새로 clone 받는 과정에서 alembric_version table 이 꼬인 것 같다.

2021.03.01 내용 추가

flask db upgrade 가 끝나지 않고 그대로 멈춰서 ctrl+z 로 나온 후 발생한 문제.

workbench로 user table을 아무리 수정하려고 해도, 하다 하다 drop을 하려고 해도 말을 안들었다.
Error 2013: connection lost만 뜨는데, 이게 아무리 봐도 연결 시간 문제는 아니었다.

우연히 찾게된 원인은 flask db upgrade가 계속 실행중이었던 것이다.
ps 로 pid를 확인한 후 kill 해주면 다시 동작한다.

Comments