Skip to content
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

Cập nhật dữ liệu hành chính đúng chuẩn #150

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from

Conversation

dungpt3003
Copy link
Collaborator

@dungpt3003 dungpt3003 commented Oct 27, 2020

Changes

  • Tạo models Xa, Huyen, Tinh mới
  • Import data theo chuẩn đơn vị hành chính.
  • Nối lại foreign key từ các bảng liên quan.

How to run

  1. Giải nén tệp đính kèm và đặt các tệp csv vào thư mục project/app/data
    data.zip
  2. Migrate dữ liệu:
python3 project/manage.py migrate

@kc97ble
Copy link
Collaborator

kc97ble commented Oct 31, 2020

Conflicting migrations detected; multiple leaf nodes in the migration graph: (0074_auto_20201027_1934, 0076_migrate_old_xa_data in app).

Ta cần sửa lại các tệp migrations. Hiện tại, tệp migration mới nhất trên nhánh develop là 0070_merge_20201027_0115.py. Tất cả các tệp migration mới được thêm cần phải được đánh số sau tệp này, và được điều chỉnh giá trị dependencies cho phù hợp.

@kc97ble
Copy link
Collaborator

kc97ble commented Oct 31, 2020

hoặc chạy lệnh python manage.py makemigrations --merge rồi push thay đổi lên nhánh này.

@kc97ble
Copy link
Collaborator

kc97ble commented Oct 31, 2020

Key (huyen_id)=(924) is not present in table "app_newhuyen"

có vẻ vẫn còn nhiều bug

@dungpt3003
Copy link
Collaborator Author

@kc97ble đã sắp xếp lại migrations và xử lý lỗi duplicate key nhé (do mới chuyển hodan và cuuho chứ chưa chuyển tinhnguyenvien nên lỗi)

454,569,Thành Phố Tam Kỳ,Thành phố Tam Kỳ
456,5387,Huyện Đông Anh,Huyện Đông Anh
459,3595,Huyện Ba Vì,Huyện Ba Vì
463,0,Chưa rõ,null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

những dòng như thế này có ảnh hưởng gì không ạ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File này để map id cũ (cột 1) với id mới (cột 2). Chỉ những huyện nào có hộ dân/đội cứu hộ thì anh mới đưa vào file này. Dòng 81 thì sẽ gán huyện "Chưa rõ" trong dữ liệu cũ về id 0. Anh thử ở local với dữ liệu mới nhất thì không ảnh hưởng gì.

@kc97ble
Copy link
Collaborator

kc97ble commented Nov 4, 2020

Cái PR này gian nan phết. Chắc phải hết bão số 10 mới merge được :(

@dungpt3003
Copy link
Collaborator Author

Cái PR này gian nan phết. Chắc phải hết bão số 10 mới merge được :(

@kc97ble Ừ chắc phải vậy em, anh sẽ thêm log các thứ để kiểm tra cho dễ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants