Skip to content
Snippets Groups Projects
Name Last commit Last update
..
README
foreign_keys.sql
patch_21_22.sql
patch_23_24.sql
patch_24_25.sql
patch_25_26.sql
patch_26_27.sql
patch_27_28.sql
patch_28_29.sql
patch_29_30.sql
patch_30_31.sql
patch_31_32.sql
patch_32_33.sql
patch_33_34.sql
patch_34_35.sql
patch_35_36.sql
patch_36_37.sql
patch_37_38.sql
patch_38_39_a.sql
patch_38_39_b.sql
patch_38_39_c.sql
patch_38_39_d.sql
patch_38_39_e.sql
patch_39_40_a.sql
patch_39_40_b.sql
patch_39_40_c.sql
patch_39_40_d.sql
patch_39_40_e.sql
patch_39_40_f.sql
patch_39_40_g.sql
patch_39_40_h.sql
patch_39_40_i.sql
patch_39_40_j.sql
patch_40_41_a.sql
patch_40_41_b.sql
patch_40_41_c.sql
patch_40_41_d.sql
patch_40_41_e.sql
patch_40_41_f.sql
patch_41_42_a.sql
patch_41_42_b.sql
patch_41_42_c.sql
patch_41_42_d.sql
patch_41_42_e.sql
patch_41_42_f.sql
patch_41_42_g.sql
patch_42_43_a.sql
patch_42_43_b.sql
patch_42_43_c.sql
patch_42_43_d.sql
patch_42_43_e.sql
patch_42_43_f.sql
patch_43_44_a.sql
patch_43_44_b.sql
patch_43_44_c.sql
patch_43_44_d.sql
patch_43_44_e.sql
patch_43_44_f.sql
patch_44_45_a.sql
patch_44_45_b.sql
patch_44_45_c.sql
patch_45_46_a.sql
patch_45_46_b.sql
patch_45_46_c.sql
patch_45_46_d.sql
patch_45_46_e.sql
patch_45_46_f.sql
patch_45_46_g.sql
patch_46_47_a.sql
patch_46_47_b.sql
patch_46_47_c.sql
patch_47_48_a.sql
patch_48_49_a.sql
patch_48_49_b.sql
patch_48_49_c.sql
patch_48_49_d.sql
patch_48_49_e.sql
patch_49_50_a.sql
patch_49_50_b.sql
patch_49_50_c.sql
patch_49_50_d.sql
patch_49_50_e.sql
patch_50_51_a.sql
patch_50_51_b.sql
patch_50_51_c.sql
patch_50_51_d.sql
patch_50_51_e.sql
patch_50_51_f.sql
patch_50_51_g.sql
patch_50_51_h.sql
patch_50_51_i.sql
patch_51_52_a.sql
patch_51_52_b.sql
patch_51_52_c.sql
patch_51_52_d.sql
patch_52_53_a.sql
patch_52_53_b.sql
patch_52_53_c.sql
patch_52_53_d.sql
patch_53_54_a.sql
*** Ensembl database schema ***

This documents describes how to load the Ensembl database schema and to use the
patches to keep your schema up-to-date between releases.


1. Creating an empty Ensembl db from scratch:
=============================================

The Ensembl database schema is defined in the file ensembl/sql/table.sql. Use
the mysql commandline client to load this schema into a new database:

a. log into your MySQL database server and create a new database.

b. load the schema into this database:

  $ mysql -h mysql_host -P 3306 -u your_username -pyour_password \
      new_ensembl_db < ensembl/sql/table.sql


2. Patching an existing Ensembl database to the latest schema:
==============================================================

For each release, the core team provides patches to bring your databases to the
latest schema. Before release 39, there was a single patch file for each
release. From release 39, the patches will be split into multiple files, each
containing one "task". The new convention for patch files (to be found in
ensembl/sql) is:

  release < 39:   patch_FROM_TO.sql
  release >= 39:  patch_FROM_TO_[a-z].sql

where FROM is the schema version before patching, TO the version to
patch to, and [a-z] is a letter specifying the respective patch.

Each patch will put an entry into the meta table (meta_key = 'patch') to
indicate that it has been applied successfully.

This meta information is also used by the patch script to determine which
patches need to be applied to a db. The patch script is
ensembl/misc-scripts/schema_patch.pl, run with --help to see all options it
accepts (from the commandline or from an ini-style configuration file passed in
with --conffile). You can patch multiple database at a time by using an
appropriate --pattern.

Note that you can still apply the patches manually if you prefer.

a. Find out the schema version of your db(s):
---------------------------------------------

Look at the 'schema_version' entry in the meta table to find out the current
schema version of your db. You will have to apply all patches from this to the
current version sequentially, e.g. if you version is 36 and you want to patch to
39, you'll have to apply patches 36->37, 37->38 and 38->39.

b. Check which patches need to be applied:
------------------------------------------

This step is optional, you can proceed to step (c) immediately if you like.

  $ ensembl/misc-scripts/schema_patch.pl --host mysql_host --port 3306 \
      --user your_username --pass your_password --pattern %_core_39_% \
      --schema 39 --dry_run 1 --interactive 0

c. Actually patch the databases:
--------------------------------

  $ ensembl/misc-scripts/schema_patch.pl --host mysql_host --port 3306 \
      --user your_username --pass your_password --pattern %_core_39_% \
      --schema 39 --logfile /your/log/path/schema_patch.39.log

The script will run interactively and prompt you for each database matching the
pattern. --logfile is optional but useful for keeping track of what you've done.