News for hackers. Stuff that matters.
Re:Why We Chose Rails to Build Gitlab by mey on Tuesday January 22, 2019 @04:41PM (#18972824)
I suggest checking out https://flywaydb.org/ It doesn't have the ORM-ness mapping rails migrate does, but it makes it really simple to organize sql scripts to move/update schema configs.
Re:Why We Chose Rails to Build Gitlab by mythrwy on Tuesday January 22, 2019 @04:50PM (#18972919)
I sometimes suspect a folder full of sql scripts would be better than black box migrations (which are a folder full of sql scripts or similar anyway).

Migrations are great, until they aren't.

Sometimes if you actually manually do the thing you know how it works better and can adjust. I suppose the drawback to that is everyone else doesn't.

Re:Why We Chose Rails to Build Gitlab by evanelias on Tuesday January 22, 2019 @11:00PM (#18975573)
Another option is a schema management tool that doesn't rely on migrations at all. I'm the author of one, Skeema [1], for MySQL/MariaDB. Others include migra [2] for Postgres, and sqldef [3] for MySQL or Postgres.

These all use a declarative approach [4], where the user just specifies the desired new state, by adding or changing the set of CREATE statements. The tool knows how to run the correct DDL to reach that new state.

[1] https://github.com/skeema/skeema

[2] https://github.com/djrobstep/migra

[3] https://github.com/k0kubun/sqldef

[4] https://www.skeema.io/blog/2019/01/18/declarative/

Re:Why We Chose Rails to Build Gitlab by mythrwy on Wednesday January 23, 2019 @02:11PM (#18981551)
How Interesting. Thanks!
Re:Why We Chose Rails to Build Gitlab by gwillz on Tuesday January 22, 2019 @05:20PM (#18973184)
Yeah I've thought the exact same thing before and I've actually tried both.

The clear difference is that migrations are easily reversible. Good migration libraries can also reverse data migrations.

A folder of SQL scripts was very refreshing, but no way could I use that system in a production environment. There's just too many edge cases to keep in your head.

Re:Why We Chose Rails to Build Gitlab by mey on Tuesday January 22, 2019 @05:29PM (#18973253)
Manually migrating has the issue of testability and hit by the bus. I don't believe every migration needs a roll back, sometimes the better strategy is restore from a snapshot/backup.
Re:Why We Chose Rails to Build Gitlab by stock_toaster on Tuesday January 22, 2019 @05:00PM (#18972995)
I personally tend to prefer migrate[1] as it doesn't require java.

[1]: https://github.com/golang-migrate/migrate

Re:Why We Chose Rails to Build Gitlab by zmmmmm on Wednesday January 23, 2019 @04:30PM (#18983200)
Java seems ideal as it will be completely cross platform and you can add / update the database drivers after the fact.

Migrate has a different binary for each platform and from what I can see, the support for each database is compiled in, so just to update a driver you are going to be maintaining that binary all over the place.

Re:Why We Chose Rails to Build Gitlab by majewsky on Tuesday January 22, 2019 @05:29PM (#18973258)
Migrate is awesome! My only issue: Since it uses bare SQL for the migrations, you have to do some lifting if you need to support multiple RDBMS with different DDLs. I have some regexes in my project to translate Postgres DDL into SQLite DDL for my test suite.
Re:Why We Chose Rails to Build Gitlab by dam5s on Tuesday January 22, 2019 @05:51PM (#18973460)
Why would you not test your code with the same RDBMS you will have in production? Especially if it’s something as easy to install as Postgres? It seems like begging for trouble...
Re:Why We Chose Rails to Build Gitlab by james-mcelwain on Tuesday January 22, 2019 @09:46PM (#18975215)
If you're using an ORM, it can be an easy way to ensure that no vendor specific stuff sneaks in. Also, until recently it was difficult to run, e.g., SQL Server in Docker, so Postgres might be easier to test with. Agreed SQLite is a weird choice, but not all integration tests are robust enough to test characteristics of the underlying db, i.e. focus on business logic not performance.
Re:Why We Chose Rails to Build Gitlab by majewsky on Thursday January 24, 2019 @07:09AM (#18987955)
I have several dozen tests that run in completely separate DBs. With SQLite, the test suite runs through in 1 second:

  $ time go test github.com/sapcc/limes/... | grep -v 'no test files'
  ok      github.com/sapcc/limes  0.004s
  ok      github.com/sapcc/limes/pkg/api  0.515s
  ok      github.com/sapcc/limes/pkg/collector    0.449s
  ok      github.com/sapcc/limes/pkg/core 0.006s
I doubt that you can setup and tear down several dozen Postgreses in that time.
Re:Why We Chose Rails to Build Gitlab by axelfontaine on Tuesday January 22, 2019 @06:03PM (#18973577)
Flyway doesn't require Java. The CLI ships with a private JRE as well as drivers for most databases out of the box. Simply untar and run.