mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Fix migrate script
This commit is contained in:
parent
84364d9018
commit
50c452c287
20
migrate.py
20
migrate.py
@ -104,7 +104,7 @@ def migrate_users():
|
|||||||
User.objects.filter(id__gt=0).delete()
|
User.objects.filter(id__gt=0).delete()
|
||||||
print("Users deleted")
|
print("Users deleted")
|
||||||
|
|
||||||
for u in c.fetchall():
|
for u in c:
|
||||||
try:
|
try:
|
||||||
new = User(
|
new = User(
|
||||||
id=u['id_utilisateur'],
|
id=u['id_utilisateur'],
|
||||||
@ -192,7 +192,7 @@ def migrate_clubs():
|
|||||||
# for k,v in club.items():
|
# for k,v in club.items():
|
||||||
# print("%40s | %40s" % (k, v))
|
# print("%40s | %40s" % (k, v))
|
||||||
|
|
||||||
for c in cur.fetchall():
|
for c in cur:
|
||||||
try:
|
try:
|
||||||
new = Club(
|
new = Club(
|
||||||
id=c['id_asso'],
|
id=c['id_asso'],
|
||||||
@ -207,7 +207,7 @@ def migrate_clubs():
|
|||||||
SELECT *
|
SELECT *
|
||||||
FROM asso
|
FROM asso
|
||||||
""")
|
""")
|
||||||
for c in cur.fetchall():
|
for c in cur:
|
||||||
club = Club.objects.filter(id=c['id_asso']).first()
|
club = Club.objects.filter(id=c['id_asso']).first()
|
||||||
parent = Club.objects.filter(id=c['id_asso_parent']).first()
|
parent = Club.objects.filter(id=c['id_asso_parent']).first()
|
||||||
club.parent = parent
|
club.parent = parent
|
||||||
@ -223,7 +223,7 @@ def migrate_club_memberships():
|
|||||||
|
|
||||||
Membership.objects.all().delete()
|
Membership.objects.all().delete()
|
||||||
print("Memberships deleted")
|
print("Memberships deleted")
|
||||||
for m in cur.fetchall():
|
for m in cur:
|
||||||
try:
|
try:
|
||||||
club = Club.objects.filter(id=m['id_asso']).first()
|
club = Club.objects.filter(id=m['id_asso']).first()
|
||||||
user = User.objects.filter(id=m['id_utilisateur']).first()
|
user = User.objects.filter(id=m['id_utilisateur']).first()
|
||||||
@ -280,7 +280,7 @@ def migrate_subscriptions():
|
|||||||
print("Subscriptions deleted")
|
print("Subscriptions deleted")
|
||||||
Customer.objects.all().delete()
|
Customer.objects.all().delete()
|
||||||
print("Customers deleted")
|
print("Customers deleted")
|
||||||
for r in cur.fetchall():
|
for r in cur:
|
||||||
try:
|
try:
|
||||||
user = Subscriber.objects.filter(id=r['id_utilisateur']).first()
|
user = Subscriber.objects.filter(id=r['id_utilisateur']).first()
|
||||||
if user:
|
if user:
|
||||||
@ -306,7 +306,7 @@ def update_customer_account():
|
|||||||
JOIN ae_cotisations cotis
|
JOIN ae_cotisations cotis
|
||||||
ON carte.id_cotisation = cotis.id_cotisation
|
ON carte.id_cotisation = cotis.id_cotisation
|
||||||
""")
|
""")
|
||||||
for r in cur.fetchall():
|
for r in cur:
|
||||||
try:
|
try:
|
||||||
user = Customer.objects.filter(user_id=r['id_utilisateur']).first()
|
user = Customer.objects.filter(user_id=r['id_utilisateur']).first()
|
||||||
if user:
|
if user:
|
||||||
@ -323,7 +323,7 @@ def migrate_counters():
|
|||||||
FROM cpt_comptoir
|
FROM cpt_comptoir
|
||||||
""")
|
""")
|
||||||
Counter.objects.all().delete()
|
Counter.objects.all().delete()
|
||||||
for r in cur.fetchall():
|
for r in cur:
|
||||||
try:
|
try:
|
||||||
club = Club.objects.filter(id=r['id_assocpt']).first()
|
club = Club.objects.filter(id=r['id_assocpt']).first()
|
||||||
new = Counter(
|
new = Counter(
|
||||||
@ -366,7 +366,7 @@ def migrate_refillings():
|
|||||||
fail = 100
|
fail = 100
|
||||||
root_cust = Customer.objects.filter(user__id=0).first()
|
root_cust = Customer.objects.filter(user__id=0).first()
|
||||||
mde = Counter.objects.filter(id=1).first()
|
mde = Counter.objects.filter(id=1).first()
|
||||||
for r in cur.fetchall():
|
for r in cur:
|
||||||
try:
|
try:
|
||||||
cust = Customer.objects.filter(user__id=r['id_utilisateur']).first()
|
cust = Customer.objects.filter(user__id=r['id_utilisateur']).first()
|
||||||
user = User.objects.filter(id=r['id_utilisateur']).first()
|
user = User.objects.filter(id=r['id_utilisateur']).first()
|
||||||
@ -404,7 +404,7 @@ def migrate_typeproducts():
|
|||||||
""")
|
""")
|
||||||
ProductType.objects.all().delete()
|
ProductType.objects.all().delete()
|
||||||
print("Product types deleted")
|
print("Product types deleted")
|
||||||
for r in cur.fetchall():
|
for r in cur:
|
||||||
try:
|
try:
|
||||||
new = ProductType(
|
new = ProductType(
|
||||||
id=r['id_typeprod'],
|
id=r['id_typeprod'],
|
||||||
@ -424,7 +424,7 @@ def migrate_products():
|
|||||||
""")
|
""")
|
||||||
Product.objects.all().delete()
|
Product.objects.all().delete()
|
||||||
print("Product deleted")
|
print("Product deleted")
|
||||||
for r in cur.fetchall():
|
for r in cur:
|
||||||
try:
|
try:
|
||||||
type = ProductType.objects.filter(id=r['id_typeprod']).first()
|
type = ProductType.objects.filter(id=r['id_typeprod']).first()
|
||||||
club = Club.objects.filter(id=r['id_assocpt']).first()
|
club = Club.objects.filter(id=r['id_assocpt']).first()
|
||||||
|
Loading…
Reference in New Issue
Block a user