Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
+-++-++-++-++-++-++-++-+ |M||i||g||r||a||t||o||r| +-++-++-++-++-++-++-++-+ I migrate your data.
Have you ever been building an application and want to track your schema modifications in a meaningful and incremental fashion? Of course you have, we all have! I, for one, had an application that I ported from Rails to express.js and one of the big things I missed was the migrations. I haven't yet ported the "rollbacks", because I didn't use them. Also I didn't port over the abstraction layer because, well people should learn SQL especially when it comes to defining schema.
migrator will process a directory of migrations, aptly named "./migrations", that are a mix of SQL and JS files and process them in ascending order, skipping over ones that have already been processed. Essentially it allows you to have a uniform way of migrating schema and data in a repeatable and dependable fashion. It comes with a executable "migrator" that assumes the following conventions:
module.exports = { "development: { "postgresql": "tcp:postgres@localhost/dev-db" }, "staging:" { "postgresql": "tcp:postgres@localhost/stage-db" }, "production:" { "postgresql": "tcp:postgres@localhost/db" } }
If those conventions are hip to you then just install migrator using
sudo npm install -g migrator
and run it in the following fashion
migrator
and you are off migrating. If you don't like those conventions, configure them! The package exports a function "migrate" that you can use in the following manner:
require("migrator").migrate("app_root_path", "config_hash_with_attribute_as_above", options_hash);
For now the options hash just allows you to change the configured editor, it must be a path to the editor for auto opening new migration files. If you don't provide one, it uses your defined "EDITOR" environment variable.
If you opt for the configuration route, it's generally good to wrap it in an executable script and use it in similar manner to how you use the convention-based migrator.
To create a migration, you can just use
migrator -g
OR
migrator generate
That will create a new file with the current timestamp as an integer with the extension .sql
and open in the defined editor as described above OR the default environment variable EDITOR (run echo $EDITOR
to find out what this is for your system).
If you want to migrate data, create a JS migration using
migrator -g js
OR
migrator generate js
and it will open a new file (similar format) with the extension .js
with the necessary boilerplate to allow for the DB object to be passed in. If you do use the JS one, be sure to execute the callback parameter once all operations are done with a simple callback()
.
You got questions, I got answers (sometimes) - ping me on twitter @voodootikigod. If you like this, go out and do something awesome with it, I got your back (but not rollback, at least not yet).
FAQs
Take your datas and migrate them
The npm package migrator receives a total of 668 weekly downloads. As such, migrator popularity was classified as not popular.
We found that migrator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.