Yoyo-migrations icon

Yoyo-migrations For Linux

  n/a
BSD License    

Database schema migration tool, using SQL and DB-API. #Schema migration  #Database schema  #Database API  #Database  #Schema  #Migration  

Description

changelog

Free Download

Yoyo-migrations is a database schema migration utility using plain SQL and the DB-API.

As database applications evolve, changes to the database schema are often required. These can usually be written as one-off SQL scripts containing CREATE/ALTER table statements (although any SQL or python script may be used with yoyo-migrations).

Yoyo-migrations provides a command line tool for reading a directory of such scripts and applying them to your database as required.

PostgreSQL, MySQL and SQLite databases are supported. Usage

Yoyo-migrations is usually invoked as a command line script.

Read all migrations from directory migrations and apply them to a PostgreSQL database:

yoyo-migrate apply ./migrations/ postgres://user:password@localhost/database

Rollback migrations previously applied to a MySQL database:

yoyo-migrate rollback ./migrations/ mysql://user:password@localhost/database

Reapply (ie rollback then apply again) migrations to a SQLite database at location /home/sheila/important-data.db:

yoyo-migrate reapply ./migrations/ sqlite:////home/sheila/important-data.db

By default, yoyo-migrations starts in an interactive mode, prompting you for each migration file before applying it, making it easy to choose which migrations to apply and rollback.

The migrations directory should contain a series of migration scripts. Each migration script is a python file (.py) containing a series of steps. Each step should comprise a migration query and (optionally) a rollback query. For example:

# # file: migrations/0001.create-foo.py # step(  "CREATE TABLE foo (id INT, bar VARCHAR(20), PRIMARY KEY (id))",  "DROP TABLE foo", )

The filename of each file (without the .py extension) is used as the identifier for each migration. Migrations are applied in filename order, so it's useful to name your files using a date (eg '20090115-xyz.py') or with another incrementing number.

yoyo-migrate creates a table in your target database, _yoyo_migration, to track which migrations have been applied.

Steps may also take an optional argument ignore_errors, which must be one of apply, rollback, or all. If in the previous example the table foo might have already been created by another means, we could add ignore_errors='apply' to the step to allow the migrations to continue regardless:

# # file: 0001.create-foo.py # step(  "CREATE TABLE foo (id INT, bar VARCHAR(20), PRIMARY KEY (id))",  "DROP TABLE foo",  ignore_errors='apply', )

Steps can also be python callable objects that take a database connection as their single argument. For example:

# # file: 0002.update_keys.py # def do_step(conn):  cursor = conn.cursor()  cursor.execute(  "INSERT INTO sysinfo "  " (osname, hostname, release, version, arch)"  " VALUES (%s, %s, %s, %s, %s %s)",  os.uname()  ) step(do_step)

You normally specify your database username and password as part of the database connection string on the command line. On a multi-user machine, other users could view your database password in the process list.

The -p or --prompt-password flag causes yoyo-migrate to prompt for a password, ignoring any password specified in the connection string. This password will not be available to other users via the system's process list.

The first time you run yoyo-migrate on a new set of migrations, you will be asked if you want to cache the database connection string in a file called .yoyo-migrate in the migrations directory.

This cache is local to the migrations directory, so subsequent runs on the same migration set do not need the database connection string to be specified.

This saves typing, avoids your database username and password showing in process listings and lessens the risk of accidentally running yoyo-migrate on the wrong database (ie by re-running an earlier yoyo-migrate entry in your command history when you have moved to a different directory).

If you do not want this cache file to be used, add the --no-cache parameter to the command line options.

System requirements

What's new in Yoyo-migrations 4.2.4:

  • Fix for mismanaged 4.2.3 release
Read the full changelog

Yoyo-migrations 4.2.4

add to watchlist add to download basket send us an update REPORT
  runs on:
Linux
  filename:
yoyo-migrations-4.2.4.tar.gz
  main category:
Database
  developer:
  visit homepage

Zoom Client 6.0.3.37634

The official desktop client for Zoom, the popular video conferencing and collaboration tool used by millions of people worldwide
Zoom Client

ShareX 16.0.1

Capture your screen, create GIFs, and record videos through this versatile solution that includes various other amenities: an OCR scanner, image uploader, URL shortener, and much more
ShareX

IrfanView 4.67

With support for a long list of plugins, this minimalistic utility helps you view images, as well as edit and convert them using a built-in batch mode
IrfanView

7-Zip 23.01 / 24.04 Beta

An intuitive application with a very good compression ratio that can help you not only create and extract archives, but also test them for errors
7-Zip

Context Menu Manager 3.3.3.1

Customize Windows’ original right-click context menu using this free, portable and open-source utility meant to enhance your workflow
Context Menu Manager

Microsoft Teams 24060.3102.2733.5911 Home / 1.7.00.7956 Work

Effortlessly chat, collaborate on projects, and transfer files within a business-like environment by employing this Microsoft-vetted application
Microsoft Teams

4k Video Downloader 1.5.3.0080 Plus / 4.30.0.5655

Export your favorite YouTube videos and playlists with this intuitive, lightweight program, built to facilitate downloading clips from the popular website
4k Video Downloader

Bitdefender Antivirus Free 27.0.35.146

Feather-light and free antivirus solution from renowned developer that keeps the PC protected at all times from malware without requiring user configuration
Bitdefender Antivirus Free

calibre 7.9.0

Effortlessly keep your e-book library thoroughly organized with the help of the numerous features offered by this efficient and capable manager
calibre

Windows Sandbox Launcher 1.0.0

Set up the Windows Sandbox parameters to your specific requirements, with this dedicated launcher that features advanced parametrization
Windows Sandbox Launcher

38% discount
Bitdefender Antivirus Free
  • Bitdefender Antivirus Free
  • calibre
  • Windows Sandbox Launcher
  • Zoom Client
  • ShareX
  • IrfanView
  • 7-Zip
  • Context Menu Manager
  • Microsoft Teams
  • 4k Video Downloader
essentials


Click to load comments
This enables Disqus, Inc. to process some of your data. Disqus privacy policy