m0060: likvidace sirotku ve stromu
This commit is contained in:
parent
7bb79ce56f
commit
7f89af129f
3 changed files with 19 additions and 11 deletions
|
@ -3,8 +3,8 @@
|
|||
import psycopg2
|
||||
import psycopg2.extras
|
||||
|
||||
OLD_DB = "mam_old"
|
||||
NEW_DB = "mamweb"
|
||||
OLD_DB = "mam-prod"
|
||||
NEW_DB = "mam-test"
|
||||
|
||||
oldconn = psycopg2.connect(f"dbname={OLD_DB}")
|
||||
newconn = psycopg2.connect(f"dbname={NEW_DB}")
|
||||
|
|
|
@ -39,13 +39,13 @@ DATABASES = {
|
|||
'NAME': os.path.join(BASE_DIR, 'db-local.sqlite3'),
|
||||
}
|
||||
}
|
||||
#DATABASES = {
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
# 'NAME': 'mam_local',
|
||||
# 'USER': 'mam',
|
||||
# },
|
||||
#}
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'mam-test',
|
||||
'USER': 'kam',
|
||||
},
|
||||
}
|
||||
|
||||
# LOGGING
|
||||
LOGGING = {
|
||||
|
|
|
@ -6,6 +6,15 @@ from django.db import migrations
|
|||
|
||||
from django.db.models import Q
|
||||
|
||||
def nastav_koren(koren, node):
|
||||
node.root = koren
|
||||
node.save()
|
||||
|
||||
if node.succ:
|
||||
nastav_koren(koren, node.succ)
|
||||
if node.first_child:
|
||||
nastav_koren(koren, node.first_child)
|
||||
|
||||
def pridej_potomka(rodic, potomek):
|
||||
# Daný vrchol bude posledním potomkem rodiče
|
||||
uz_ma_deti = False
|
||||
|
@ -23,8 +32,7 @@ def pridej_potomka(rodic, potomek):
|
|||
posledni = posledni.succ
|
||||
|
||||
# Nastavíme kořen:
|
||||
potomek.root = rodic.root
|
||||
potomek.save()
|
||||
nastav_koren(rodic.root, potomek)
|
||||
|
||||
# Připojíme vrchol:
|
||||
if uz_ma_deti:
|
||||
|
|
Loading…
Reference in a new issue