mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-04 20:51:00 +00:00
Test troublesome migration 0019
This commit is contained in:
@ -1,14 +1,21 @@
|
||||
# Generated by Django 2.2.10 on 2020-04-13 06:42
|
||||
|
||||
import sys
|
||||
import os
|
||||
from rapidfuzz import fuzz
|
||||
|
||||
from django.db import migrations, connection
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
|
||||
"""
|
||||
When this migration is tested by CI, it cannot accept user input.
|
||||
So a simplified version of the migration is implemented.
|
||||
"""
|
||||
TESTING = 'test' in sys.argv
|
||||
|
||||
def clear():
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
if not TESTING:
|
||||
os.system('cls' if os.name == 'nt' else 'clear')
|
||||
|
||||
|
||||
def reverse_association(apps, schema_editor):
|
||||
@ -222,23 +229,31 @@ def associate_manufacturers(apps, schema_editor):
|
||||
clear()
|
||||
|
||||
# Present a list of options
|
||||
print("----------------------------------")
|
||||
if not TESTING:
|
||||
print("----------------------------------")
|
||||
|
||||
print("Checking part [{pk}] ({idx} of {total})".format(pk=part_id, idx=idx+1, total=total))
|
||||
print("Manufacturer name: '{n}'".format(n=name))
|
||||
print("----------------------------------")
|
||||
print("Select an option from the list below:")
|
||||
|
||||
if not TESTING:
|
||||
print("Manufacturer name: '{n}'".format(n=name))
|
||||
print("----------------------------------")
|
||||
print("Select an option from the list below:")
|
||||
|
||||
print("0) - Create new manufacturer '{n}'".format(n=name))
|
||||
print("")
|
||||
print("0) - Create new manufacturer '{n}'".format(n=name))
|
||||
print("")
|
||||
|
||||
for i, m in enumerate(matches[:10]):
|
||||
print("{i}) - Use manufacturer '{opt}'".format(i=i+1, opt=m))
|
||||
for i, m in enumerate(matches[:10]):
|
||||
print("{i}) - Use manufacturer '{opt}'".format(i=i+1, opt=m))
|
||||
|
||||
print("")
|
||||
print("OR - Type a new custom manufacturer name")
|
||||
print("")
|
||||
print("OR - Type a new custom manufacturer name")
|
||||
|
||||
while True:
|
||||
response = str(input("> ")).strip()
|
||||
if TESTING:
|
||||
# When running unit tests, simply select the name of the part
|
||||
response = '0'
|
||||
else:
|
||||
response = str(input("> ")).strip()
|
||||
|
||||
# Attempt to parse user response as an integer
|
||||
try:
|
||||
@ -300,18 +315,19 @@ def associate_manufacturers(apps, schema_editor):
|
||||
print("")
|
||||
clear()
|
||||
|
||||
print("---------------------------------------")
|
||||
print("The SupplierPart model needs to be migrated,")
|
||||
print("as the new 'manufacturer' field maps to a 'Company' reference.")
|
||||
print("The existing 'manufacturer_name' field will be used to match")
|
||||
print("against possible companies.")
|
||||
print("This process requires user input.")
|
||||
print("")
|
||||
print("Note: This process MUST be completed to migrate the database.")
|
||||
print("---------------------------------------")
|
||||
print("")
|
||||
if not TESTING:
|
||||
print("---------------------------------------")
|
||||
print("The SupplierPart model needs to be migrated,")
|
||||
print("as the new 'manufacturer' field maps to a 'Company' reference.")
|
||||
print("The existing 'manufacturer_name' field will be used to match")
|
||||
print("against possible companies.")
|
||||
print("This process requires user input.")
|
||||
print("")
|
||||
print("Note: This process MUST be completed to migrate the database.")
|
||||
print("---------------------------------------")
|
||||
print("")
|
||||
|
||||
input("Press <ENTER> to continue.")
|
||||
input("Press <ENTER> to continue.")
|
||||
|
||||
clear()
|
||||
|
||||
|
Reference in New Issue
Block a user