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

Need to automate database schema updates #1297

Closed
RJPercival opened this issue Sep 18, 2018 · 5 comments
Closed

Need to automate database schema updates #1297

RJPercival opened this issue Sep 18, 2018 · 5 comments

Comments

@RJPercival
Copy link
Contributor

When we have changed the database schema in the past, we have expected users to either delete and recreate their database (e.g. with scripts/resetdb.sh), or apply schema changes manually (after reverse-engineering them from commits). Users have complained that this (amongst other things) makes it painful to update Trillian. Instead, we should provide database schema migration scripts, e.g. a directory of SQL files containing files such as "increase_display_name_length.sql":

ALTER TABLE Trees ALTER COLUMN DisplayName VARCHAR (100)

We would no longer change the schema itself, but instead add SQL migration scripts to apply the changes we'd like. This does, admittedly, make seeing what the final schema looks like a bit harder - I'm open to suggestions on how to improve this.

@RJPercival
Copy link
Contributor Author

@AlCutter has suggested Skeema may be a good tool for automating our schema updates.

@RJPercival
Copy link
Contributor Author

Skeema works for MySQL schema updates, but not for Cloud Spanner (or Postgres, but that's not a supported storage backend at the moment). I've experimented with using github.com/golang-migrate/migrate instead (RJPercival@b1a4594), which does support Cloud Spanner, but it relies on us writing migration scripts and shipping them in the binaries, and managing a version number for each database schema (so it's more work than Skeema to maintain).

@RJPercival
Copy link
Contributor Author

I investigated doing migrations using Terraform, but this isn't supported for either Cloud Spanner or MySQL (using the most widely used providers, at least).

@RJPercival RJPercival removed their assignment Feb 26, 2020
@mhutchinson mhutchinson self-assigned this May 26, 2022
@mhutchinson
Copy link
Contributor

We aren't making schema changes recently. What we'll do to somewhat address this is add the schemas to a restricted code-owner review, and ensure that no breaking schema changes are made without some kind of documentation or process on upgrading.

@AlCutter AlCutter mentioned this issue May 26, 2022
2 tasks
mhutchinson added a commit to mhutchinson/trillian that referenced this issue May 26, 2022
This isn't a perfect solution, but it's a pragmatic solution that fixes google#1297 enough for how much we are making changes
@mhutchinson mhutchinson assigned AlCutter and unassigned mhutchinson May 26, 2022
@mhutchinson
Copy link
Contributor

Fixed by #2746

robstradling added a commit to robstradling/trillian that referenced this issue Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants