Closed ficofer closed 4 years ago
Hey Fernando, I think you're running into an issue that #9 should resolve. Could you try running your migration with @nbuchwitz's branch? You'll have to manually build it from https://github.com/nbuchwitz/grafana-sqlite-to-postgres
If it works for you, then it should be OK to merge in :)
@wbh1 Will, thanks for the prompt reply using @nbuchwitz definitely help or at least let me move on to the following error, I am trying to understand it as it seems to be a syntax error in some conversion ?
What could be the approach to help out fixing this edge cases maybe to make it error prune ?
FATAL[2020-05-03T18:42:28+01:00] ❌ pq: invalid input syntax for type integer: "" INSERT INTO "dashboard" VALUES(1,8,'new-user','New user','{"annotations":{"list":[]},"editable":true,"hideControls":false,"id":1,"links":[],"originalTitle":"New user","rows":[{"collapse":false,"editable":true,"height":"250px","panels":[{"aliasColors":{},"bars":true,"datasource":null,"editable":true,"error":false,"fill":1,"grid":{"leftLogBase":1,"leftMax":null,"leftMin":null,"rightLogBase":1,"rightMax":null,"rightMin":null,"threshold1":null,"threshold1Color":"rgba(216, 200, 27, 0.27)","threshold2":null,"threshold2Color":"rgba(234, 112, 112, 0.22)"},"id":3,"isNew":true,"legend":{"alignAsTable":true,"avg":false,"current":false,"max":false,"min":false,"rightSide":true,"show":true,"total":true,"values":true},"lines":false,"linewidth":2,"links":[],"nullPointMode":"connected","percentage":false,"pointradius":5,"points":false,"renderer":"flot","seriesOverrides":[{"alias":"index","bars":false,"fill":0,"lines":true,"linewidth":1}],"span":12,"stack":true,"steppedLine":false,"targets":[{"refId":"A","target":"aliasByNode(summarize(master.*.stats.claim.number.*, ''1d'', ''sum'', false), 5)"},{"hide":true,"refId":"B","target":"aliasByNode(summarize(master.*.stats.claim.index, ''1d'', ''sum'', false), 4)"}],"timeFrom":null,"timeShift":null,"title":"Claim Origin","tooltip":{"shared":true,"value_type":"individual"},"type":"graph","x-axis":true,"y-axis":true,"y_formats":["short","short"]}],"title":"Row"},{"collapse":false,"editable":true,"height":"250px","panels":[{"aliasColors":{},"bars":true,"datasource":null,"editable":true,"error":false,"fill":1,"grid":{"leftLogBase":1,"leftMax":null,"leftMin":null,"rightLogBase":1,"rightMax":null,"rightMin":null,"threshold1":null,"threshold1Color":"rgba(216, 200, 27, 0.27)","threshold2":null,"threshold2Color":"rgba(234, 112, 112, 0.22)"},"id":2,"isNew":true,"legend":{"alignAsTable":true,"avg":false,"current":false,"max":false,"min":false,"rightSide":true,"show":true,"total":true,"values":true},"lines":false,"linewidth":2,"links":[],"nullPointMode":"connected","percentage":false,"pointradius":5,"points":false,"renderer":"flot","seriesOverrides":[],"span":12,"stack":true,"steppedLine":false,"targets":[{"refId":"A","target":"aliasByNode(summarize(master.*.stats.new_account.*, ''1d'', ''sum'', false), 4)"}],"timeFrom":null,"timeShift":null,"title":"New Account","tooltip":{"shared":true,"value_type":"individual"},"type":"graph","x-axis":true,"y-axis":true,"y_formats":["short","short"]}],"title":"New row"}],"schemaVersion":8,"sharedCrosshair":false,"style":"dark","tags":[],"templating":{"list":[]},"time":{"from":"now-60d","to":"now"},"timepicker":{"now":true,"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"]},"timezone":"browser","title":"New user","version":8}',1,'2016-01-26 00:00:46','2016-01-26 00:26:07','',0,0,'',0,0,0,'000000001') - failed to import dump file to Postgres.
INSERT INTO "dashboard" VALUES(1,8,'new-user','New user','{"annotations":{"list":[]},"editable":true,"hideControls":false,"id":1,"links":[],"originalTitle":"New user","rows":[{"collapse":false,"editable":true,"height":"250px","panels":[{"aliasColors":{},"bars":true,"datasource":null,"editable":true,"error":false,"fill":1,"grid":{"leftLogBase":1,"leftMax":null,"leftMin":null,"rightLogBase":1,"rightMax":null,"rightMin":null,"threshold1":null,"threshold1Color":"rgba(216, 200, 27, 0.27)","threshold2":null,"threshold2Color":"rgba(234, 112, 112, 0.22)"},"id":3,"isNew":true,"legend":{"alignAsTable":true,"avg":false,"current":false,"max":false,"min":false,"rightSide":true,"show":true,"total":true,"values":true},"lines":false,"linewidth":2,"links":[],"nullPointMode":"connected","percentage":false,"pointradius":5,"points":false,"renderer":"flot","seriesOverrides":[{"alias":"index","bars":false,"fill":0,"lines":true,"linewidth":1}],"span":12,"stack":true,"steppedLine":false,"targets":[{"refId":"A","target":"aliasByNode(summarize(master.*.stats.claim.number.*, ''1d'', ''sum'', false), 5)"},{"hide":true,"refId":"B","target":"aliasByNode(summarize(master.*.stats.claim.index, ''1d'', ''sum'', false), 4)"}],"timeFrom":null,"timeShift":null,"title":"Claim Origin","tooltip":{"shared":true,"value_type":"individual"},"type":"graph","x-axis":true,"y-axis":true,"y_formats":["short","short"]}],"title":"Row"},{"collapse":false,"editable":true,"height":"250px","panels":[{"aliasColors":{},"bars":true,"datasource":null,"editable":true,"error":false,"fill":1,"grid":{"leftLogBase":1,"leftMax":null,"leftMin":null,"rightLogBase":1,"rightMax":null,"rightMin":null,"threshold1":null,"threshold1Color":"rgba(216, 200, 27, 0.27)","threshold2":null,"threshold2Color":"rgba(234, 112, 112, 0.22)"},"id":2,"isNew":true,"legend":{"alignAsTable":true,"avg":false,"current":false,"max":false,"min":false,"rightSide":true,"show":true,"total":true,"values":true},"lines":false,"linewidth":2,"links":[],"nullPointMode":"connected","percentage":false,"pointradius":5,"points":false,"renderer":"flot","seriesOverrides":[],"span":12,"stack":true,"steppedLine":false,"targets":[{"refId":"A","target":"aliasByNode(summarize(master.*.stats.new_account.*, ''1d'', ''sum'', false), 4)"}],"timeFrom":null,"timeShift":null,"title":"New Account","tooltip":{"shared":true,"value_type":"individual"},"type":"graph","x-axis":true,"y-axis":true,"y_formats":["short","short"]}],"title":"New row"}],"schemaVersion":8,"sharedCrosshair":false,"style":"dark","tags":[],"templating":{"list":[]},"time":{"from":"now-60d","to":"now"},"timepicker":{"now":true,"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"]},"timezone":"browser","title":"New user","version":8}',1,'2016-01-26 00:00:46','2016-01-26 00:26:07','',0,0,'',0,0,0,'000000001');
May be its the double quoting ?
--Edit--
As if it were not grabbing/replacing the empty spaces correctly?
LINE 1: ...8}',1,'2016-01-26 00:00:46','2016-01-26 00:26:07','',0,0,'',...
^
I believe the issue that you're hitting is that the value that is being attempted to be inserted into the updated_by
column of the dashboard
table is an empty string rather than NULL (I believe SQLite treats them basically the same but PostgreSQL does not).
I'm not sure of a good way to programmatically map empty strings in integer
-typed columns to NULL
. In the interim, I would suggest updating this dashboard in SQLite using:
update dashboard set updated_by = 1 where updated_by is NULL;
@wbh1 that did the job, instead of doing it agains NULL I did it against EMPTY (not sure the diff but against NULL was still failing.
update dashboard set updated_by = 1 where updated_by is '';
@wbh1 Will, thanks a lot for this amazing tool is really useful.
I am working in a project where I need to migrate from sqlite to Postgres running on RDS, before going to the actual AWS system I am testing this locally (a couple of containers running on my machine)
All seems to go as expected, overcame already some issues with manually (outside of grafana created tables) needed in the new psql to actually insert the info into them... but this one I am not able to workaround.
sqlite.db --> ~ 170mb
The error:
The
/tmp/grafana.sql