
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
The links that associate us.
The schema of the database is managed through migration files that can be applied or rolled back to ensure the database version matches the expected version of the server.
NOTE: Currently only PostgreSQL is tested with this method.
To create a migration, create a new SQL file in the migrations folder with the format XXXX_my_migration.sql where the XXXX should be the next migration number in sequence and the text describes the migration. You can use the catena command to do this as long as you're in the project root:
$ go run ./cmd/catena --new my revision name
In the SQL file you should have the following two comments:
-- migrate: up
-- insert up migration sql here
-- migrate: down
-- insert down migration sql here
All of the SQL under -- migrate: up will be run when the migration is applied and all of the SQL under -- migrate: down will be run if the migration is rolled back. Ensure that you separate multiple SQL commands with ; because they will be executed all at once and with newlines removed.
Next generate the migration by running go generate in the project root:
$ go generate ./...
This will generate the migrations code from the SQL files and allow you to apply it with the catena migrate command.
The goal of catena is to do as much as possible from scratch in order to demonstrate an extremely lightweight web api server and concepts such as database migration, context handling, logging, tracing, etc. This is primarily for the purposes of my deeper exploration of Go rather than to develop a production-grade API.
When it comes to route multiplexing however, the http.ServeMux is an excellent example of static routing but does not scale well to the dynamic routing required by a REST API. In the past I've attempted to implement a prefix trie for this routing, but in order to focus on other efforts in this code, I've selected httprouter based on its lightweight tree structure and benchmarks. Potentially in the future I will attempt to write my own radix tree structure and benchmark it specifically to this API - but for now it provides the smallest abstraction set and allows me to focus on middleware and the API itself.
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.