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

Correct sqlite-to-postgres column mapping #1828

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

eth3lbert
Copy link
Contributor

The backend column was added later to the pstat_series table.
This PR reorders the column order to comply with the schema.

Closes #1827

@Kobzol
Copy link
Contributor

Kobzol commented Mar 1, 2024

That's interesting. The backend column was indeed added later, but after this migration, backend should be before metric. So it probably depends on which version of the SQLite table you have when doing the export.

@eth3lbert
Copy link
Contributor Author

Interesting! What would you expect in this situation? Perhaps adding some columns mapping strategy?

@eth3lbert
Copy link
Contributor Author

Oh wait! In SQLite, the backend column is placed before the metric column. However, in PostgreSQL, it remains after the metric column.

@Kobzol
Copy link
Contributor

Kobzol commented Mar 1, 2024

Oh, good find, I made this error when writing the last migration. It's a PITA to keep these two DB backends in sync.

@eth3lbert
Copy link
Contributor Author

Yep, and it seems somewhat inevitable. I think it would be reasonable to introduce some column mapping to avoid these kinds of issues in the future.

@Kobzol
Copy link
Contributor

Kobzol commented Mar 1, 2024

Yeah, the conversion script should probably be able to support different column order in both backends.

@eth3lbert
Copy link
Contributor Author

Or, we could try passing columns to functionsqlite_attributes and return a mapped and ordered columns back.
The column names are available through

select name from PRAGMA_TABLE_INFO('table_name') order by cid

@Kobzol
Copy link
Contributor

Kobzol commented Mar 1, 2024

This is a bit outside of my current SQL-fu, but if it works, let's go for it :)

Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable. I assume that the conversion now works for you, after the latest commit?

@eth3lbert
Copy link
Contributor Author

Yes, works as expected.

P.S. I just made some minor wording changes and added information about the panics.

@Kobzol Kobzol merged commit c8960a1 into rust-lang:master Mar 2, 2024
11 checks passed
@eth3lbert eth3lbert deleted the fix-sqlite2pg branch March 2, 2024 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect Column Mapping in sqlite-to-postgres
2 participants