IRC logs of #tryton for Thursday, 2019-11-07

chat.freenode.net #tryton log beginning Thu 07 Nov 2019 12:00:01 AM CET
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton23:44
-!- sebste_(~sebste@x4db49055.dyn.telefonica.de) has joined #tryton01:35
-!- yangoon(~mathiasb@202-162-142-46.pool.kielnet.net) has joined #tryton03:55
-!- rpit(~rpit@p200300C88F32F600A22070230F535743.dip0.t-ipconnect.de) has joined #tryton07:22
-!- sebste(~sebste@x4db49055.dyn.telefonica.de) has joined #tryton07:49
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton07:56
-!- cedk(~ced@gentoo/developer/cedk) has joined #tryton08:00
-!- Timitos(~kpreisler@2001:a61:5a4:b101:762b:62ff:fe84:ed7e) has joined #tryton08:02
-!- rpit(~rpit@p4FFB778E.dip0.t-ipconnect.de) has joined #tryton09:23
-!- nicoe(~nicoe@213.211.148.72) has joined #tryton09:43
sebsteGood morning, folks. I am doing a migration from sqlite to postgres and i am taking notes for a writeup which I would like to make available for "the next guy". I am struggling a bit, thoug.09:51
sebsteHere is what I have done so far: setup pgsql server and created user and database.09:52
sebsteRan trytond-admin on that database to create the tables.09:52
sebstecreated a schema of that db09:52
sebstedroped db and recreated it with the schema to get empty tables.09:52
sebstenow I want to run sqlite3pgsql.py from the tryton-tools.09:53
sebsteHere is the problem:09:53
sebstepsycopg2.ProgrammingError: column "active" is of type boolean but expression is of type integer09:54
sebsteLINE 1: ...VALUES (1,NULL,'Administration','tryton-settings',1,'2019-06...09:54
sebsteHINT:  You will need to rewrite or cast the expression.09:54
sebsteSo what would be the best wa to tackle this? Can I modify the script to automatically convert the fields?09:55
cedksebste: this seems to be a solution https://dba.stackexchange.com/questions/46140/have-postgresql-accept-1-and-0-as-true-and-false-for-boolean09:58
sebstecedk: thanks! I'll try that!10:01
sebstecedk: the first suggested method, update pg_cast, does not seem to have an effect.10:09
sebstemaybe I could use pgloader instead...10:10
sebsteseond thought: I just did "update pg_cast set castcontext='a' where casttarget = 'boolean'::regtype;" as postgres in psql, then reran psqlite2pgsl ist this correct?10:12
cedksebste: you should maybe use 'i' instead of 'a'10:20
cedkas the query use VALUES instead of assignation10:21
cedkhttps://www.postgresql.org/docs/current/catalog-pg-cast.html10:21
sebsteNo, does not work - I am in doubt if I perfom this settings in the rigth place, though10:24
cedksebste: it must be done on the database10:25
sebstecedk: Thanks that seems to do the trick! Makes sense ;-)10:28
sebsteHere comes teh next one:10:29
sebstepsycopg2.ProgrammingError: column "dashboard_layout" of relation "res_user" does not exist10:29
sebsteLINE 1: ...eset_expire","signature","write_date","write_uid","dashboard...10:29
sebstecan I just add the colum by modifying the schema and recreating the database?10:29
cedksebste: it is probably better to drop the column from the source10:30
sebstecedk: you mean in the sqlite db, right?10:30
cedksebste: wait this should exist in the target10:31
cedksebste: I guess you did not activate the same modules on both10:31
sebstehmm shoot! That could be. Unfortunately ther old modules are gone since I downgraded to 4.8 because of an update problem. I had to recreate the modules list manually.10:36
sebstewhat module would res_user likely be part of?10:36
cedksebste: do not understand the question10:39
sebstecedk: never mind, I'll try to figure it out. I was wondering if one could tell which module might be the wrong one.10:41
cedksebste: dashboard10:41
sebstethanks!10:43
sebstecedk: if I uninstall module dashboard and run trytond-admin, will it get rid of the related db entries / tables11:21
sebsteor the other way around. How do I cleanly uninstall a module in tryton?11:25
cedksebste: clean uninstall is not supported11:32
sebstecedk: Your note on migration from 4.2 to4.4: https://discuss.tryton.org/t/migration-from-5-2-to-5-4/1547 does that also apply to sqlite?12:00
-!- nicoe(~nicoe@213.211.148.72) has joined #tryton12:02
sebsteOK, so back to where it all started: I got everything back to a runing tryton 5.2 installation and pip upgraded all modules to 5.4.0. Running trytond-admin fails though: https://pastebin.com/YkEUNCxk12:33
sebsteUnfortnately I have no clue where to look next12:36
cedksebste: I do not think it applies on sqlite because it has any of the types12:37
cedksebste: well sqlite does not seem to support DISTINCT ON syntax12:43
sebstecedk: so that means migration from 5.2 to 5.4 does not work on sqlite?12:45
sebsteI was hoping to get everything on 5.4 and migrate to postgres afterwards12:46
cedkI filled https://python-sql.tryton.org/bug6412:47
cedksebste: indeed I think nobody ever test migration on SQLite as it is for testing purpose only12:47
sebstecedk: ok, I see. Seems I am locked-in right now. The problem with mooving 4.2 over to postgres is, that I had accidentally installed the dashboard module of 5.4. This seems to be the reason why I cant import my data to postgresql. So I was hoping I could iron things out by updating to 5.4 on sqlite and do the move later, when the tables match.  I have accumulated a lot of configuration and data during testing and it would be cool to keep that12:56
sebstedata. Do you think it makes sense to wait for a bugfix? I would also help if I knew what to do.12:56
pokolisebste: probably the best is to migrate from sqlite to postgres first, and them upgrade the tryton series12:57
sebstepokoli: yes, I tried that an was almost successfull. Problem is that I had a mixup with a mudule version, so that my data is not compatible with the new datbase structure. :-(12:59
sebsteI f I could get rid of the tables related to dashboard module in my current installation in sqlite, it would probably load just fine into the postgresql db13:00
pokolisebste: indeed you only need to create on postgresql the columns on common tables13:01
pokolisebste: and then you can remove it13:01
sebstepokoli: sorry?13:02
pokolisebste: you should manually create all the columns created on the dashboard module on the postgres database, so the import script will create the data (altought you don't need it)13:03
pokolisebste: without installing the dashboard module13:04
-!- springwurm(~Springwur@5.104.149.54) has joined #tryton13:04
pokolisebste: once you have the data migrated to postgresql you can remove the manually created columns13:04
sebstepokoli: well I did use trytond-admin to install the tables in the new datbase, then made a dump with just the schema, droped the db and recreated it from the schema to have empty tables13:07
pokolisebste: so when you load the data into postgres you get some errors of missing columns, don't you?13:08
sebsteexactely13:09
pokolisebste: so if you create this columns manually (without installing the module) you will be able to migrate the data13:09
pokolisebste: and once you have it migrated you can remove the columns to get rid of uneeded columns13:09
sebstepokoli: I would think so13:09
sebsteproblem is I am not sure what colum to put where and how13:10
sebsteapparently I suck a databases :-D13:11
pokolisebste: I think you only need to add a VARCHAR named dasbhoar_layout to res_user table13:12
sebstepokoli: alright, I 'll try that later.13:13
sebstefunny thing is, that the column doe snot get created by trytond-admin despite the fact that the module is installed13:13
sebsteThank you guys (both) so much for your help an patience, again, you are awesome!13:14
cedkI pushed a patch for https://python-sql.tryton.org/bug6413:24
cedksebste: if the column is not created, it means the module is not activated13:25
cedksebste: I do not know if you want or not this module but you must have the same set of modules activated on both13:25
sebstecedk: yes, I have13:28
cedksebste: I do not understand13:29
sebste:x13:31
pokolicedk: IIUC he has the dasboard module on a sqlite database but does not want it on the postgres database13:31
cedkpokoli: this is not possible to switch without having same module sets13:32
sebsteactually i don't mind it being there. it is just, that tratond-admin did not create the columns in res_user despite the fact, that the module is installed13:33
sebstein the new db, that is13:33
sebsteI am currently trying to add the missing columns manually13:33
cedksebste: I suspect you did not activate it13:50
cedksebste: just relaunch trytond-admin -u dashboard13:50
-!- mariomop(~quassel@181.228.29.59) has joined #tryton14:15
sebstecedk: I think you are right. I forgot I need to run trytond-admin twice. Just creating the new schema. Hope the data goes in aftewards.15:07
sebsteOK, so far so good. At least I got a step further. But now when run sqlite2pg.py I get this:15:10
sebstepsycopg2.IntegrityError: insert or update on table "res_user" violates foreign key constraint "res_user_menu_fkey"15:10
sebsteDETAIL:  Key (menu)=(2) is not present in table "ir_action".15:10
cedksebste: it happens, SQLite does not enforce foreign key15:12
cedksebste: so you have to clean up the data in the source15:12
sebstecedk: So can I just update the rows of res_user to contain the id of the "menu" entry of ir_action in the field menu?15:25
sebstewhich would be 2 in my case15:26
sebste2|1|2019-06-13 17:49:32.558392|0||Menu|ir.action.act_window|menu|2019-06-13 17:49:32.580188|015:26
sebstewell, that didn't work15:32
cedksebste: why 2, from the error message 2 does not exist15:36
sebstecedk: but if I do SELECT * FROM ir_action WHERE id = 2;15:39
sebstei get 2|1|2019-06-13 17:49:32.558392|0||Menu|ir.action.act_window|menu|2019-06-13 17:49:32.580188|015:39
sebsteI am sorry - it is a messy learning curve15:40
cedksebste: I think you must use a schema without constraint on PG and add the constraint after15:52

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!