-
Notifications
You must be signed in to change notification settings - Fork 119
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
Add support for ?dialect=postgresql to /api/migrations #956
Conversation
5d932fd
to
f573c5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is exactly the way to do it. maybe we should sort out that type field in the migration message now though. what is it for? i'm guessing the intention was to make the schema info available to the clients without them having to parse the migration sql, In which case what's the best way to pass that? we could have a generic structure that gave the base type as a string and any modifiers (like length, precision etc) as a map or something? if we knew we were only ever going to support sqlite and pg, then what we have works but that makes me wary.
} | ||
end | ||
|
||
defp replication_msg_table_col(%Proto.Column{} = column, dialect) do | ||
defp replication_msg_table_col(%Proto.Column{} = column) do | ||
%SatOpMigrate.Column{ | ||
name: column.name, | ||
pg_type: replication_msg_table_col_type(column.type), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my original {sqlite,pg}_type
thing makes no sense. why don't we just have type
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I left both sqlite_type
and pg_type
here to avoid breaking existing code, as this was a POC. I did mark both as deprecated in the protocol definition, so ideally only type_info
should remain.
But as of #1054, Kevin and I encountered some TypeScript typing issues with type_info
. Long story short, the latest iteration of this changes now lives in #1065 where sqlite_type
is deprecated (can be removed today, just needs some client-side tests for /api/migrations
updated) and only pg_type
remain as the source of truth for the column type.
columns: [ | ||
%SatOpMigrate.Column{ | ||
name: "id", | ||
sqlite_type: "TEXT", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the pg_type
bit carries the original type info dropped by the conversion to sqlite's type. hmm. perhaps just dropping the sqlite_
prefix and having a dialect-defined type
which is just a string?
We have the From looking at the client code, it doesn't need So we can drop |
sqlite_type is not needed and pg_type is replaced by type_info.
f2579d6
to
12e769b
Compare
Closes VAX-1659.
Passing
?dialect=postgresql
to/api/migrations
will now result in the returned migrations to have the original Postgres DDL.