GithubHelp home page GithubHelp logo

dmitryvinn / onlineschemachange Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookincubator/onlineschemachange

0.0 1.0 0.0 1.25 MB

A tool for performing online schema changes on MySQL.

License: Other

Python 99.95% PLpgSQL 0.05%

onlineschemachange's Introduction

OnlineSchemaChange

Support Ukraine - Help Provide Humanitarian Aid to Ukraine.

OnlineSchemaChange is a tool for making schema changes for MySQL tables in a non-blocking way

Examples

OSC must be run on the same host as MySQL server.

copy mode

Say we have an existing table named my_table under database test:

CREATE TABLE `my_table` (
  `id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Now if we want to run ALTER TABLE `my_table` add column `data` varchar(10); against it. Instead of feed the ALTER TABLE statement to OSC, we just need to put a CREATE TABLE statement representing the desired schema into a file /tmp/foo.sql like below:

CREATE TABLE `my_table` (
  `id` int(11) NOT NULL,
  `data` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Then run the following command:

osc_cli copy --ddl-file-list=foo.sql --socket=/tmp/mysql.socket --database=test

cleanup mode

To cleanup the table left behind by last run of OSC

osc_cli cleanup --socket=/tmp/mysql.socket --database=test

To terminate a currently running OSC process on certain MySQL Instance:

osc_cli cleanup

direct mode

This mode is reserved for utilizing MySQL's native online ddl for schema change, and help DBA manage all the schema related operation into this one tool. For now, if you plan to use OSC for all your schema management, this mode is here for you to create a empty new table. Following command will create an empty table into database test

osc_cli direct --ddl-file-list=foo.sql --socket=/tmp/mysql.socket --database=test

Requirements

OnlineSchemaChange requires

System packages

sudo apt-get install python3-dev # debian / Ubuntu
sudo yum install python3-devel # Red Hat / CentOS

Python requirements * python >= 3.5 * python module: pyparsing, MySQLdb

Installing OnlineSchemaChange

Run following command to install dependency

python setup.py install --install-scripts=/usr/local/bin

If you have multiple python version available in your environment, or you don't want mess up with system's default python, you can use pyenv and virtualenv

How OnlineSchemaChange works

Check wiki page for more detail, and some advanced usage.

How to contribute

Check this wiki page if you want to contribute to this project.

License

OnlineSchemaChange is BSD-licensed.

onlineschemachange's People

Contributors

cenalulu avatar knapst3r avatar srinivasmohan avatar adregner avatar preritj24 avatar apahim avatar luqun avatar amyreese avatar macisamuele avatar krallin avatar yizhang82 avatar yoshinorim avatar adamchainz avatar zertosh avatar dmitryvinn avatar george-reynya avatar fried avatar zpao avatar fspv avatar piperchester avatar rahul-singhal avatar 100ll avatar graingert avatar yashtc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.