paupino / psqlpack

A logical database management system for PostgreSQL enabling incremental database deployment.
Apache License 2.0
8 stars 2 forks source link

Beginning of column modification logic/tests #83

Closed paupino closed 6 years ago

paupino commented 6 years ago

This is the start of the column modification logic.

I suspect we'll want to add further validation rules about what can and cannot be changed somewhere. Validation rules returned from generate could be an interesting extension. I'm thinking it could return a vector of "Violations" which the publish profile could then "filter" before potentially erroring out if more exist. This is more for things like changing a binary type to an int or something stupid.

This PR ignores changing table constraints at a column level at the moment, e.g. adding UNIQUE or removing UNIQUE at a column level. These are anonymous table level constraints so we'll need to likely extend the AST to support these types as well as loop through them as part of #30.

One other change in this PR is the merging of delta.rs and profiles.rs into a single publish.rs. I've been struggling remembering what each file is responsible for; this is perhaps a step towards association each file with the operation it's closely tied to.

Anyway, keen to hear your thoughts on

justinlatimer commented 6 years ago

So, the delta represents the diff of 2 states, publish_profile is the options used to generate it.

delta was a separate file because it's used for all the operations (script is generating a delta and then turning that into SQL, report is generating the delta and rendering that as a report etc)

Not sure the 2 files should be merged, but not super against it either.

paupino commented 6 years ago

Yeah, I see your point re breaking out delta.rs. Perhaps the logical separation then is:

  1. delta.rs contains the diff logic
  2. sql.rs contains the impl for generating sql (i.e. this may get more complex)
  3. xyz.rs contains the impl for generating xyz

In terms of publish profiles - since they define delta generation they could be kept in the same file? I actually made this all part of a separate commit so it's easy to roll back if need be :)

paupino commented 6 years ago

@justinlatimer I reverted back to keeping the files separate. We can have a chat about the strategy we want to take over slack later on.