Project

scheman

0.02
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
SQL schema parser.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.6
>= 0
>= 0
= 2.14.1

Runtime

 Project Readme

Scheman Build Status

Note

This project is archived because I no longer actively use it, and there seems to be no recent activity from other users either. If you are still using it and would like to take over maintenance, contact me somewhere.

SQL schema parser.

Usage

Create diff from 2 schema files or input.

# before.sql
CREATE TABLE `table1` (
  `column1` INTEGER(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `column2` DATETIME DEFAULT NOW()
);

CREATE TABLE `table2` (
  `column1` INTEGER(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`column1`)
);
# after.sql
CREATE TABLE `table1` (
  `column1` CHAR(11) NOT NULL AUTO_INCREMENT,
  `column2` DATETIME DEFAULT CURRENT_TIMESTAMP(),
  `column3` VARCHAR(255) NOT NULL DEFAULT "a",
  PRIMARY KEY (`column2`)
);

CREATE TABLE `table3` (
  `column1` INTEGER(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`column1`)
);
$ scheman diff --before before.sql --after after.sql
BEGIN;

SET foreign_key_checks=0;

CREATE TABLE `table3` (
  `column1` INTEGER(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`column1`)
);

ALTER TABLE `table1` ADD COLUMN `column3` VARCHAR(255) NOT NULL DEFAULT "a",
  CHANGE COLUMN `column1` CHAR(11) NOT NULL AUTO_INCREMENT,
  DROP PRIMARY KEY,
  ADD PRIMARY KEY `column2`;

DROP TABLE `table2`;

SET foreign_key_checks=1;

COMMIT;

STDIN

You can input schema data into scheman diff command via STDIN, instead of --before. For instance, this interface is useful when you want to use mysqldump command to get your current schema.

$ mysqldump --no-data --compact db_name | scheman diff --after after.sql

./schema.sql

Scheman use ./schema.sql as a default value of --after option.

$ mysqldump --no-data --compact db_name | scheman diff

Pipes

Here is an example workflow of schema modification, using UNIX pipes.

$ vi schema.sql
$ mysqldump --no-data --compact db_name | scheman diff | mysql db_name

Rails

scheman-rails provides some rake tasks to use scheman with Rails.