Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dynamic Column Adjustments #38

Open
wbh1 opened this issue Oct 16, 2022 · 4 comments
Open

feat: Dynamic Column Adjustments #38

wbh1 opened this issue Oct 16, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@wbh1
Copy link
Owner

wbh1 commented Oct 16, 2022

Currently, I hardcode all the tables/columns with boolean types that need to be converted when doing imports. This is tedious and difficult to maintain. Instead, we should dynamically determine which columns need adjustment.

Some options:

  • Run queries on sqlite to find tables/columns ahead of time
  • Use expected error messages to dynamically retry with conversion
    • I like this one less.

Related issues

@wbh1 wbh1 added the enhancement New feature or request label Oct 16, 2022
@bumarcell
Copy link

Is this error related? :(
INFO[2022-11-03T10:10:04Z] 📁 SQLlite file: /grafana.db INFO[2022-11-03T10:10:04Z] 📁 Dump directory: /tmp INFO[2022-11-03T10:10:04Z] ✅ sqlite3 command exists INFO[2022-11-03T10:10:07Z] ✅ sqlite3 database dumped to /tmp/grafana.sql INFO[2022-11-03T10:10:07Z] ✅ CREATE statements removed from dump file INFO[2022-11-03T10:10:09Z] ✅ sqlite3 dump sanitized INFO[2022-11-03T10:10:10Z] ✅ migration_log statements removed INFO[2022-11-03T10:10:10Z] ✅ char keyword transformed INFO[2022-11-03T10:10:11Z] ✅ hex-encoded data decoded FATAL[2022-11-03T10:11:19Z] ❌ pq: column "is_revoked" is of type boolean but expression is of type integer INSERT INTO "api_key" VALUES(1,1,'argocd','721b6988520348318be28ff74596c450f980f1fe44eec295168bc8439821a751c202e93bbd885aa94d3ade39ce23267369f7','Editor','2022-09-03 13:26:12','2022-09-03 13:26:12',1977571572,NULL,'2022-11-03 09:44:32',0) - failed to import dump file to Postgres.

@wbh1
Copy link
Owner Author

wbh1 commented Nov 3, 2022

@bumarcell yep! To fix that, the table/column needs to be added to this file: https://github.com/wbh1/grafana-sqlite-to-postgres/blob/master/pkg/postgresql/tablechanges.go

@bumarcell
Copy link

bumarcell commented Nov 3, 2022

Many thanx 🙏

Also worthy of noting is that my other two DCs didn't have that problem, although all have an API key which isn't revoked (is_revoked=false) but it worked without problems -> I checked the postgres and the value was f

@komkomissarov
Copy link

Today I encountered the same issue, but I opted for a simpler solution since I had only one API key – I simply deleted it. The migration went smoothly, and now everything is working.

Grafana 10.0.2
SQLite to Postgres 14

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants