5 ms·
Using no frameworks at all, only https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter for routing.
by taneltanel 9y ago
Using no frameworks at all, only https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter for routing.
- taneltanel 9y agoAnd https://github.com/gorilla/sessions https://github.com/gorilla/sessions for sessions.
- deleted 9y ago[deleted]
- Gonzih 9y agoYeah, I had really good experience with httprouter also. Everything in production is based on it.
- bauerd 9y agoHow do you handle database schema migrations?
- grey-area 9y agoI use SQL migrations for this, works fine. Only migrate up, never down, and store the name of migrations already run in the db.
- binarray2000 9y agoCould you please clarify. Which one of these do you mean (first three results when googling SQL migrations): (1) https://www.npmjs.com/package/sql-migrations https://www.npmjs.com/package/sql-migrations (2) https://flywaydb.org/documentation/migration/sql https://flywaydb.org/documentation/migration/sql (3) https://github.com/rubenv/sql-migrate https://github.com/rubenv/sql-migrate
- grey-area 9y agoNone of the above, sorry I didn't mean a tool called 'sql migrations' I meant I simply use sql files (rather than having a special language or config file that translates to sql which is another common approach). I use something I wrote myself (see link in other comment). Nothing fancy and could be replicated easily - save sql files for migrations, run migration if not in db already, then store in the db the name of the migration run.
- jzelinskie 9y agoThe best generic tool/library for migrations that I've found is https://github.com/remind101/migrate https://github.com/remind101/migrate We're using it in production on a few CoreOS projects.
- aczerepinski 9y agoMigrations are a minor pain point for me. The libraries I've used don't support running (all) pending migrations; only those with a timestamp more recent than the previous one. This means we have to finesse the timestamps manually as migrations get merged into the main branch and deployed to various environments. As such, the value offered by the migration library is pretty minimal compared to just remembering to pipe a .sql file directly into the database. Hopefully there's a more robust option out there that I just haven't found yet.
- grey-area 9y agoI take the approach of storing the name of any migrations run in the database in a metadata table - this means you can run them out of order, restore from a backup then run migrations not yet run etc. to test or adjust them. With multiple devs it's often the case that we want to run things out of order on production too, so ordering by time doesn't work and running manually is error-prone. Code for this here - it'd be pretty simple to put it in its own little tool or even a bash script or something, and there are surely some other tools that do something similar... This one psql only as it relies on the psql binary to load the sql, but hopefully gives you the idea. I haven't bothered developing it further to do things like run a single migration or down migrations as haven't required that so far. https://github.com/fragmenta/fragmenta/blob/master/migrate.go https://github.com/fragmenta/fragmenta/blob/master/migrate.g...
- NateDad 9y agowe use https://github.com/jackc/tern https://github.com/jackc/tern for migrations. It's pretty nice.
- camus2 9y agohttps://godoc.org/github.com/rubenv/sql-migrate https://godoc.org/github.com/rubenv/sql-migrate
- l-p 9y agoI toyed with this: https://github.com/mattes/migrate https://github.com/mattes/migrate Quite simple, does the job.
- tptacek 9y agoI use Rails migrations, via the standalone_migrations gem, and code-generate the basic CRUD Go stuff from the schema. I've tried a bunch of other migration tools but I don't think anyone has done a better job of it than Rails has.
- bauerd 9y agoCool, because this is actually what I ended up with myself in a dummy Go setup of mine (after having reinvented AR's migrations poorly with a Bash script). I'm not really accustomed to Go's ecosystem yet, so: >and code-generate the basic CRUD Go stuff from the schema I guess you read schema.rb and output some structs and methods? Because a quick Google search only yielded some Yeoman plugins …
- tptacek 9y agoNo, I use Postgres and just query information_schema, and use the row/column information to populate text/template Go templates. There's a bunch of tools that do this already (one I know works is "xo"), but I wanted join-table support.
- adibalcan 9y agoI use Django OR and it has migrations system included
- johnnycarcin 9y agoYes, this. One of the things I love about go is the stdlib capabilities. I try to avoid a lot of frameworks as there seems to be too much "magic" going on that you end up having to figure out when it comes time to troubleshoot. The HttpRouter is bare bones enough to understand and build on top of while still adding some value and helping avoid creating boilerplate code on your own.