Comments (4)
I think that a wrapper around github.com/rubenv/sql-migrate
in Horizon looks good. What I would change is:
- Remove latest.sql file. It seems that it has to be updated after adding a new migration file. Why not just run migrations?
- I personally don't like the
go-bindata
compilation step. It's commited to the Git repo and causes merge conflicts, it's impossible to check during a review (compiles human-readable text to hex) and it's not part of our build process (so it's easy to forget). What about simply using multiline strings to import SQL into Go code?
Any thoughts @nullstyle? I would like to use the final system in #378 but I don't want to start coding before talking to you.
from go.
Remove latest.sql file. It seems that it has to be updated after adding a new migration file. Why not just run migrations?
They serve different purposes, especially when you get to a large number of migrations. The latest schema allows a new database to go from empty to the correct schema without all of the intermediary steps. This becomes important when you hit 50+ migrations.
It's commited to the Git repo and causes merge conflicts, it's impossible to check during a review (compiles human-readable text to hex) and it's not part of our build process (so it's easy to forget).
Automate it. The only reason it is in the current state is because the current setup works for me (I don't forget to run go generate
) and no one else has done any work to improve it.
What about simply using multiline strings to import SQL into Go code?
Editting SQL in a multiline string sucks hardcore IMO
from go.
They serve different purposes, especially when you get to a large number of migrations. The latest schema allows a new database to go from empty to the correct schema without all of the intermediary steps. This becomes important when you hit 50+ migrations.
I think it's not big deal even with a larger number of migrations. These are usually simple schema changes so applying them shouldn't take that long. Going from empty DB to the latest schema is only done once, so even if the process takes 1-2 minute (which shouldn't be that long even for hundreds schema migrations given that creating tables, adding indexes on empty tables or removing/adding fields are operations that take miliseconds) I think it's fine.
Automate it. The only reason it is in the current state is because the current setup works for me (I don't forget to run go generate) and no one else has done any work to improve it.
I agree that automating this can solve "forgot to run go generate
" issues but other issues: hard to read diffs and conflicts are still there. What about this:
- Let's continue compiling migration files.
- Remove the compiled files from Git and add them to
.gitignore
. - Add
go generate
step to CI process and update README build instructions.
Now, compiled files are not part of Git (so do not appear in diffs and can't cause conflicts).
from go.
I think it's not big deal even with a larger number of migrations. These are usually simple schema changes so applying them shouldn't take that long. Going from empty DB to the latest schema is only done once, so even if the process takes 1-2 minute (which shouldn't be that long even for hundreds schema migrations given that creating tables, adding indexes on empty tables or removing/adding fields are operations that take miliseconds) I think it's fine.
It's not just about runtime performance. It's also about simplicity of action at runtime. One set of SQL statements (that you can inspect in a single text editor) is much easier to debug for an end user than "migration 22 of 50" failed. This lesson is not a new on, it comes from years and years of working with migrations in the RoR world: http://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you
Now, compiled files are not part of Git (so do not appear in diffs and can't cause conflicts).
Two notes:
- The hard to read diffs aren't really due to migrations... it's due to the test scenarios. Each migration causes three diff hunks: the new migration file, the patch to
latest.sql
and the updatedbindata.go
. I'm fine withbindata.go
being in.gitignore
. Nikhil is working on a system to clean up the diffs caused by the test scenarios. - We want
latest.sql
in the commit history. It is the system of record for the latest horizon db schema and having a history of how it changes is valuable.
from go.
Related Issues (20)
- Cursor Pagination Issue on Stellar Horizon Server v2.26.1 (also v2.28.1)
- goreplay middleware crashes after few minutes
- Detect Horizon DB query degradation in release candidates
- services/horizon: emit new metrics counters for timeouts HOT 3
- The stellar-horizon program cannot download stellar-history.json HOT 1
- horizon: meta should be returned as null rather than empty when `SKIP_TXMETA` enabled HOT 2
- stellar-horizon startup doesn't look normal HOT 2
- update go version to 1.22
- [epic] dry-run horizon database truncation
- Improve Scaling documentation
- horizon: consolidate logging/metrics reporting to a single route
- configured HISTORY_RETENTION_COUNT but disk size is growing HOT 3
- services/horizon: add integration test to cover sponsorship change on claimable balance
- services/horizon: add metrics for ingestions failures and alert on them
- services/horizon: log meta when ingestion engine failures occur
- Investigate Horizon High Memory Issues HOT 1
- StateVerification when on pubnet may trigger slow ingestion of new ledgers, warnings on Metastream reads HOT 2
- Filter Soroban Transactions from `fee_stats` HOT 5
- Align naming convention to `cursor`
- Audit table scans in Horizon DB
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.