Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
e6c1eab
AB-334: Setup to directly access Musicbrainz Database
rsh7 May 18, 2018
cf9bb35
Database name as in brainzutils and update requirements.txt
rsh7 May 19, 2018
42e3802
AB-334: Update documentation for setting up MusicBrainz database
rsh7 May 20, 2018
4b3b3d5
Convert documentation to markdown syntax
rsh7 May 21, 2018
3a3e9c6
Add recent BrainzUtils version
rsh7 Jun 5, 2018
6c0bfb9
AB-338: Create MusicBrainz schema in AB and add tables
rsh7 May 26, 2018
d84c898
AB:338: Add sql commands for MB tables in db testing script and fix t…
rsh7 May 26, 2018
3a979cd
AB-338: Add primary and foreign keys for MusicBrainz tables
rsh7 May 26, 2018
67ff744
Create indexes for columns of MB tables and add update script for sch…
rsh7 May 26, 2018
fe1186a
Add a condition to create schema command
rsh7 May 26, 2018
ec7e8ca
Add separate sql files for musicbrainz schema, table, indexes, primar…
rsh7 Jun 7, 2018
ae72050
Add a function to initiate MB db and a command to initialize & create…
rsh7 Jun 7, 2018
dd80e11
Correct the create musicbrainz foreign keys file
rsh7 Jun 7, 2018
98ef544
Add more indexes to musicbrainz indexes file and add an update file
rsh7 Jun 13, 2018
8d9b43a
Update the musicbrainz schema update sql file and delete the separate…
rsh7 Jun 13, 2018
dc1c999
AB-340: Import MusicBrainz data into separate schema tables in AB dat…
rsh7 Jun 5, 2018
41e0937
Add commands to start the import in readme
rsh7 Jun 5, 2018
131b4c4
Get data in batches, 10000 recordings data at a time and make code mo…
rsh7 Jun 11, 2018
c0931ca
Get data for FK referenced tables, write docstrings & comments for ev…
rsh7 Jun 13, 2018
5b38820
Remove repeated MB db initialization command
rsh7 Jun 13, 2018
5f4b1b3
Write docstrings in imperative mood
rsh7 Jun 14, 2018
4853ebc
AB-344: Add a force recreate musicbrainz schema option
rsh7 Jun 16, 2018
038f204
Add a line to print a message of dropping the schema and capitalize f…
rsh7 Jun 16, 2018
ddaa587
AB-343: Add number of recording per batch in config.py
rsh7 Jun 16, 2018
1552006
AB-342: Improve logging during MusicBrainz data import
rsh7 Jun 17, 2018
ac856e1
AB-346: Import MusicBrainz data for every new recording added to AB db
rsh7 Jun 20, 2018
4154ff1
Include table name in - No Data Found - message
rsh7 Jun 21, 2018
5bba175
Add new musicbrainz_importer module with a musicbrainz_importer scrip…
rsh7 Jun 21, 2018
39dd8c9
Import recordings in batches and pick the limit from config file
rsh7 Jun 22, 2018
e0c644f
AB-345: Log the amount of time taken to import MB data in AB
rsh7 Jun 17, 2018
62c8f6b
Move the sql query function to db module, remove offset and remove on…
rsh7 Jun 22, 2018
6b9446d
Change name of the mb importer script
rsh7 Jun 22, 2018
5cdc482
Use % style format in the print message & remove .format
rsh7 Jun 22, 2018
1e89e86
AB-347: Use logging in place of print in db/import_mb_data script
rsh7 Jun 22, 2018
8b636b9
Replace print with logging in time status message
rsh7 Jun 23, 2018
2945a7d
Move a function to db/data.py file
rsh7 Jun 27, 2018
5987d44
Add tests for getting new recordings from lowlevel
rsh7 Jun 27, 2018
f462fef
Get data for more foreign key dependent tables
rsh7 Jun 28, 2018
46e8ebb
Use key names instead of integer indexes & use set-comprehension for …
rsh7 Jul 4, 2018
340d81b
Add more documentations to specify the definition of function argumen…
rsh7 Jul 4, 2018
2591757
Import data by including more foreign key referenced tables
rsh7 Jul 4, 2018
5042cba
Functions to import and write data for track gid redirect table
rsh7 Jul 5, 2018
8ff1ecb
Import data in track table for every new_id in track gid redirect data
rsh7 Jul 5, 2018
24eaf6c
Reorder the import of a module
rsh7 Jul 5, 2018
8ffcf1e
Add more explainations about the arguments in docstrings
rsh7 Jul 8, 2018
a0fc75c
Enable logging.info to log messages in the mb importer script
rsh7 Jul 11, 2018
37bad8e
Write correct arguments for load_script function
rsh7 Jul 11, 2018
4946b31
Reduce import time by removing inner joins with recording table and r…
rsh7 Jun 28, 2018
8e2ea36
Remove DISTINCT keyword from a track gid redirect function and modify…
rsh7 Jul 5, 2018
9cc47e9
Change order of calling functions to write the data into tables
rsh7 Jul 5, 2018
a7da54c
Remove the redundant variable gids_in_Ab from all function's parameter
rsh7 Jul 5, 2018
30e8348
Add more documentation for new function's parameters and update some …
rsh7 Jul 5, 2018
6513180
Update some docstrings
rsh7 Jul 6, 2018
8d64b95
Improve some queries whose number of rows in actual MB db is less tha…
rsh7 Jul 6, 2018
9a0e0f2
Add DISTINCT in queries, otherwise there was a lot duplications in th…
rsh7 Jul 6, 2018
6ab4a5e
Add detailed docs to artist_credit_from_recording argument in all fun…
rsh7 Jul 11, 2018
ebf14b0
Change format of select queries
rsh7 Jul 12, 2018
34c6dcf
Change docstrings to include details of fetching complete data for so…
rsh7 Jul 12, 2018
a1e2cf0
Include a sleep schedule of 5 seconds after every batch import
rsh7 Jul 24, 2018
70bc938
Add a sleep for every batch import in import_mb_data script as well
rsh7 Jul 24, 2018
5d0c76e
Move sleep variables to config file
rsh7 Jul 24, 2018
0ac8b9a
Change the sleep info message in musicbrainz importer script
rsh7 Jul 24, 2018
076c18f
Change the sleep info message in import-mb_data script
rsh7 Jul 24, 2018
0306048
Tests for writing data into musicbrainz schema tables
rsh7 Jul 21, 2018
d4155eb
Add tests in modular form for area, artist & gid_redirect, artist_cre…
rsh7 Aug 3, 2018
a445334
Add tests to load and write recording and recording_gid_redirect tables
rsh7 Aug 3, 2018
587c81f
Add tests to load and write release and release_gid_redirect tables
rsh7 Aug 3, 2018
5ac347f
Add tests to load and write release_group and release_group_gid_redir…
rsh7 Aug 3, 2018
293a36b
Add tests to load and write medium table
rsh7 Aug 3, 2018
9ada2b5
Add tests to load and write track and track_gid_redirect tables
rsh7 Aug 3, 2018
6ce054d
Change testing order of release and release_group tables
rsh7 Aug 3, 2018
57a705c
Remove a big function for load and write as it is broken into modules…
rsh7 Aug 3, 2018
d125f89
Remove unnecessary comments and new lines
rsh7 Aug 3, 2018
51b827f
Add docstrings for all the test functions
rsh7 Aug 3, 2018
7e7bda1
Add release_gid_redirect fetch and write code, missed in the previous…
rsh7 Aug 3, 2018
5c64ffa
redirect mbids to their original entities and returns recordings ids …
rsh7 Jul 28, 2018
4532eb1
Add docstrings to the function definitions in get_entities.py script
rsh7 Jul 28, 2018
82708fe
Upgrade to recent BrainzUtils version and import utils.py in the script
rsh7 Aug 2, 2018
96d5f1b
Add a return statement to return gids_with_redirect_ids dict
rsh7 Aug 6, 2018
5e21584
Move the query to the db module in data.py file
rsh7 Aug 6, 2018
bf133c0
Rename musicbrainz db variable to mb_db to avoid confusion
rsh7 Aug 6, 2018
f63e854
Merge pull request #291 from rsh7/mbid_redirects
paramsingh Aug 7, 2018
b11e2a7
Add replication_control table, config variables & call statement
rsh7 Jul 5, 2018
e0b6be7
Add a script to apply replication packets in musicbrainz schema
rsh7 Jul 7, 2018
088e6eb
Add a query to drop the replication control table for testing
rsh7 Jul 7, 2018
81704b8
Include one more new line between functions
rsh7 Jul 24, 2018
85cc905
Use print_function to ease future python3 changes
rsh7 Jul 27, 2018
1a2fffe
Remove un useful print statements
rsh7 Jul 27, 2018
e876054
passing variables in the query and getting values from corresponding …
rsh7 Jul 27, 2018
2db838b
Add MIT license for apply_replication_script with copyright
rsh7 Jul 27, 2018
15f407f
Add docstrings containing the explanations for the working of functions
rsh7 Jul 30, 2018
ebca22b
change formatting style of get_data_from_musicbrainz function
rsh7 Jul 31, 2018
608782b
Remove print statement for commit transacrtion message and add newlines
rsh7 Jul 31, 2018
e5749dd
Move print message of replication sequence number just before downloa…
rsh7 Jul 31, 2018
cf16600
Include a skip message for tables not in the AB database
rsh7 Jul 31, 2018
d7089ea
Add more documentation to the functions and improve a print message
rsh7 Jul 31, 2018
90ff6eb
Add a new line between 2 functions
rsh7 Aug 4, 2018
1e76653
Add docstrings for the general functions to load and insert data
rsh7 Aug 4, 2018
2fdfd37
Correct indentation in insert function and convert int2str in a print…
rsh7 Aug 5, 2018
0653a4b
Add a space in a print message
rsh7 Aug 5, 2018
7e5190b
Move skip changes message to the outer loop
rsh7 Aug 5, 2018
9f190aa
Remove a useless print statement
rsh7 Aug 12, 2018
4b615bc
Move the queries to the db module
rsh7 Aug 12, 2018
0a43c08
Move update and write replication sequence queries to db module
rsh7 Aug 12, 2018
0566d77
Close the tar file
rsh7 Aug 12, 2018
acae8b7
Passing the variables in query and their values in a dictionary
rsh7 Aug 12, 2018
302ab50
Add docstrings to get sequence functions in data.py
rsh7 Aug 12, 2018
8a07943
Add proper formatting in query functions
rsh7 Aug 12, 2018
0253dfa
Merge pull request #282 from rsh7/apply_replication
paramsingh Aug 14, 2018
13ada58
Evaluate both db access methods by simply getting data from lowlevel …
rsh7 Aug 11, 2018
8884214
Add a limit to the number of recordings fetched
rsh7 Aug 11, 2018
e58f15a
Add logging instead of print and change file name in manage.py
rsh7 Aug 11, 2018
5adf1a5
Move queries inside the db module
rsh7 Aug 12, 2018
bf6873a
Add docstrings for the functions moved to db module
rsh7 Aug 12, 2018
f7fa076
Evaluate a functionality of mbid redirects for both db access methods
rsh7 Aug 12, 2018
6c42c4a
Add comments stating the explainations of some lines of code
rsh7 Aug 12, 2018
a815672
Merge pull request #292 from rsh7/evaluation
amCap1712 Jun 7, 2021
0f5b4c4
Merge remote-tracking branch 'origin/master' into musicbrainz-integra…
amCap1712 Jun 9, 2021
f64afa3
Fix requirements.txt after merge
amCap1712 Jun 9, 2021
8f78f60
Fix command name
amCap1712 Jun 9, 2021
a3ab871
Add missing keyword argument to command
amCap1712 Jun 9, 2021
dd3c834
Fix write_language query
amCap1712 Jun 9, 2021
92f3ab5
Add :id to language insert query
amCap1712 Jun 9, 2021
97f24c8
Drop constraints before importing data
amCap1712 Jun 9, 2021
f9c80c9
Create PKs always
amCap1712 Jun 9, 2021
8624df1
Separate access methods to evaluate separately
amCap1712 Jun 10, 2021
afcf826
Add method to fetch data directly from AB as well
amCap1712 Jun 10, 2021
de998f5
Add method to evaluate fetch using exists
amCap1712 Jun 10, 2021
d5f3250
Add commands to test with a dataset
amCap1712 Jun 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,83 @@ In order to load a psql session, use the following command:

./develop.sh psql

### Setup the MusicBrainz Server

MusicBrainz database containing all the MusicBrainz metadata is needed for
setting up your application. The ``mbdump.tar.bz2`` is the core MusicBrainz
archive which includes the tables for artist, release_group etc.
The ``mbdump-derived.tar.bz2`` archive contains annotations, user tags and search indexes.
These archives include all the data required for setting up an instance of
AcousticBrainz.

You can import the database dumps by downloading and importing the data in
a single command:

docker-compose -f docker/docker-compose.dev.yml run musicbrainz_db

**Note**

One can also manually download the dumps and then import it:-

1. For this, you have to download the dumps ``mbdump.tar.bz2`` and ``mbdump-derived.tar.bz2``
from http://ftp.musicbrainz.org/pub/musicbrainz/data/fullexport/.

**Warning**

Make sure to get the latest dumps

2. Then the environment variable ``DUMPS_DIR`` must be set to the path of the
folders containing the dumps. This can be done by:

export DUMPS_DIR="Path of the folder containing the dumps"

You can check that the variable ``DUMPS_DIR`` has been succesfully assigned or not by:

echo $DUMPS_DIR

This must display the path of your folder containing the database dumps. The folder must contain at least the file ``mbdump.tar.bz2``.

3. Then import the database dumps by this command:

docker-compose -f docker/docker-compose.dev.yml run -v $DUMPS_DIR:/home/musicbrainz/dumps \
-v $PWD/data/mbdata:/var/lib/postgresql/data/pgdata musicbrainz_db

**Note**

You can also use the smaller sample dumps available at http://ftp.musicbrainz.org/pub/musicbrainz/data/sample/
to set up the MusicBrainz database. However, note that these dumps are .tar.xz
dumps while AcousticBrainz currently only supports import of .tar.bz2 dumps.
So, a decompression of the sample dumps and recompression into .tar.bz2 dumps
will be needed. This can be done using the following command:

xzcat mbdump-sample.tar.xz | bzip2 > mbdump.tar.bz2

**Warning**

Keep in mind that this process is very time consuming, so make sure that you don't delete the ``data/mbdata`` directory accidently. Also make sure that you have about 25GB of free space to keep the MusicBrainz data.

Initialization of AcousticBrainz database is also required:

./develop.sh run --rm webserver python2 manage.py init_db

Then you can start all the services:

./develop.sh up --build

## Initialize the MusicBrainz database:

./develop.sh run --rm webserver python2 manage.py init_mb_db

## Import the MusicBrainz database in AcousticBrainz database:

./develop.sh run --rm webserver python2 manage.py import_musicbrainz_db

### Manually

Full installation instructions are available in [INSTALL.md](https://github.com/metabrainz/acousticbrainz-server/blob/master/INSTALL.md) file. After installing, continue the following steps.

## Configuration and development

### Building static files

We use webpack as our JavaScript/CSS build system.
Expand Down
175 changes: 175 additions & 0 deletions admin/sql/create_musicbrainz_foreign_keys.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
BEGIN;

ALTER TABLE musicbrainz.artist
ADD CONSTRAINT artist_fk_type
FOREIGN KEY (type)
REFERENCES musicbrainz.artist_type(id);

ALTER TABLE musicbrainz.artist
ADD CONSTRAINT artist_fk_area
FOREIGN KEY (area)
REFERENCES musicbrainz.area(id);

ALTER TABLE musicbrainz.artist
ADD CONSTRAINT artist_fk_gender
FOREIGN KEY (gender)
REFERENCES musicbrainz.gender(id);

ALTER TABLE musicbrainz.artist
ADD CONSTRAINT artist_fk_begin_area
FOREIGN KEY (begin_area)
REFERENCES musicbrainz.area(id);

ALTER TABLE musicbrainz.artist
ADD CONSTRAINT artist_fk_end_area
FOREIGN KEY (end_area)
REFERENCES musicbrainz.area(id);

ALTER TABLE musicbrainz.artist_credit_name
ADD CONSTRAINT artist_credit_name_fk_artist_credit
FOREIGN KEY (artist_credit)
REFERENCES musicbrainz.artist_credit(id)
ON DELETE CASCADE;

ALTER TABLE musicbrainz.artist_credit_name
ADD CONSTRAINT artist_credit_name_fk_artist
FOREIGN KEY (artist)
REFERENCES musicbrainz.artist(id)
ON DELETE CASCADE;

ALTER TABLE musicbrainz.artist_gid_redirect
ADD CONSTRAINT artist_gid_redirect_fk_new_id
FOREIGN KEY (new_id)
REFERENCES musicbrainz.artist(id);

ALTER TABLE musicbrainz.area
ADD CONSTRAINT area_fk_type
FOREIGN KEY (type)
REFERENCES musicbrainz.area_type(id);

ALTER TABLE musicbrainz.area_type
ADD CONSTRAINT area_type_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.area_type(id);

ALTER TABLE musicbrainz.recording
ADD CONSTRAINT recording_fk_artist_credit
FOREIGN KEY (artist_credit)
REFERENCES musicbrainz.artist_credit(id);

ALTER TABLE musicbrainz.recording_gid_redirect
ADD CONSTRAINT recording_gid_redirect_fk_new_id
FOREIGN KEY (new_id)
REFERENCES musicbrainz.recording(id);

ALTER TABLE musicbrainz.release
ADD CONSTRAINT release_fk_artist_credit
FOREIGN KEY (artist_credit)
REFERENCES musicbrainz.artist_credit(id);

ALTER TABLE musicbrainz.release
ADD CONSTRAINT release_fk_release_group
FOREIGN KEY (release_group)
REFERENCES musicbrainz.release_group(id);

ALTER TABLE musicbrainz.release
ADD CONSTRAINT release_fk_status
FOREIGN KEY (status)
REFERENCES musicbrainz.release_status(id);

ALTER TABLE musicbrainz.release
ADD CONSTRAINT release_fk_packaging
FOREIGN KEY (packaging)
REFERENCES musicbrainz.release_packaging(id);

ALTER TABLE musicbrainz.release
ADD CONSTRAINT release_fk_language
FOREIGN KEY (language)
REFERENCES musicbrainz.language(id);

ALTER TABLE musicbrainz.release
ADD CONSTRAINT release_fk_script
FOREIGN KEY (script)
REFERENCES musicbrainz.script(id);

ALTER TABLE musicbrainz.release_gid_redirect
ADD CONSTRAINT release_gid_redirect_fk_new_id
FOREIGN KEY (new_id)
REFERENCES musicbrainz.release(id);

ALTER TABLE musicbrainz.track
ADD CONSTRAINT track_fk_recording
FOREIGN KEY (recording)
REFERENCES musicbrainz.recording(id);

ALTER TABLE musicbrainz.track
ADD CONSTRAINT track_fk_medium
FOREIGN KEY (medium)
REFERENCES musicbrainz.medium(id);

ALTER TABLE musicbrainz.track
ADD CONSTRAINT track_fk_artist_credit
FOREIGN KEY (artist_credit)
REFERENCES musicbrainz.artist_credit(id);

ALTER TABLE musicbrainz.track_gid_redirect
ADD CONSTRAINT track_gid_redirect_fk_new_id
FOREIGN KEY (new_id)
REFERENCES musicbrainz.track(id);

ALTER TABLE musicbrainz.release_group
ADD CONSTRAINT release_group_fk_artist_credit
FOREIGN KEY (artist_credit)
REFERENCES musicbrainz.artist_credit(id);

ALTER TABLE musicbrainz.release_group
ADD CONSTRAINT release_group_fk_type
FOREIGN KEY (type)
REFERENCES musicbrainz.release_group_primary_type(id);

ALTER TABLE musicbrainz.release_group_primary_type
ADD CONSTRAINT release_group_primary_type_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.release_group_primary_type;

ALTER TABLE musicbrainz.release_group_gid_redirect
ADD CONSTRAINT release_group_gid_redirect_fk_new_id
FOREIGN KEY (new_id)
REFERENCES musicbrainz.release_group(id);

ALTER TABLE musicbrainz.medium
ADD CONSTRAINT medium_fk_release
FOREIGN KEY (release)
REFERENCES musicbrainz.release(id);

ALTER TABLE musicbrainz.medium
ADD CONSTRAINT medium_fk_format
FOREIGN KEY (format)
REFERENCES musicbrainz.medium_format(id);

ALTER TABLE musicbrainz.medium_format
ADD CONSTRAINT medium_format_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.medium_format(id);

ALTER TABLE musicbrainz.release_status
ADD CONSTRAINT release_status_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.release_status(id);

ALTER TABLE musicbrainz.release_packaging
ADD CONSTRAINT release_packaging_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.release_packaging(id);

ALTER TABLE musicbrainz.gender
ADD CONSTRAINT gender_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.gender(id);

ALTER TABLE musicbrainz.artist_type
ADD CONSTRAINT artist_type_fk_parent
FOREIGN KEY (parent)
REFERENCES musicbrainz.artist_type(id);

COMMIT;
67 changes: 67 additions & 0 deletions admin/sql/create_musicbrainz_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
BEGIN;

CREATE UNIQUE INDEX artist_idx_gid ON musicbrainz.artist (gid);
CREATE INDEX artist_idx_name ON musicbrainz.artist (name);
CREATE INDEX artist_idx_sort_name ON musicbrainz.artist (sort_name);
CREATE INDEX artist_idx_area ON musicbrainz.artist (area);
CREATE INDEX artist_idx_begin_area ON musicbrainz.artist (begin_area);
CREATE INDEX artist_idx_end_area ON musicbrainz.artist (end_area);

CREATE UNIQUE INDEX artist_idx_null_comment ON musicbrainz.artist (name) WHERE comment IS NULL;
CREATE UNIQUE INDEX artist_idx_uniq_name_comment ON musicbrainz.artist (name, comment) WHERE comment IS NOT NULL;

CREATE UNIQUE INDEX area_type_idx_gid ON musicbrainz.area_type (gid);

CREATE UNIQUE INDEX area_idx_gid ON musicbrainz.area (gid);
CREATE INDEX area_idx_name ON musicbrainz.area (name);

CREATE INDEX artist_credit_name_idx_artist ON musicbrainz.artist_credit_name (artist);

CREATE UNIQUE INDEX recording_idx_gid ON musicbrainz.recording (gid);
CREATE INDEX recording_idx_name ON musicbrainz.recording (name);
CREATE INDEX recording_idx_artist_credit ON musicbrainz.recording (artist_credit);

CREATE UNIQUE INDEX release_idx_gid ON musicbrainz.release (gid);
CREATE INDEX release_idx_name ON musicbrainz.release (name);
CREATE INDEX release_idx_release_group ON musicbrainz.release (release_group);
CREATE INDEX release_idx_artist_credit ON musicbrainz.release (artist_credit);

CREATE UNIQUE INDEX track_idx_gid ON musicbrainz.track (gid);
CREATE INDEX track_idx_recording ON musicbrainz.track (recording);
CREATE INDEX track_idx_name ON musicbrainz.track (name);
CREATE INDEX track_idx_artist_credit ON musicbrainz.track (artist_credit);

CREATE INDEX artist_gid_redirect_idx_new_id ON musicbrainz.artist_gid_redirect (new_id);

CREATE INDEX recording_gid_redirect_idx_new_id ON musicbrainz.recording_gid_redirect (new_id);

CREATE INDEX release_gid_redirect_idx_new_id ON musicbrainz.release_gid_redirect (new_id);

CREATE INDEX release_group_gid_redirect_idx_new_id ON musicbrainz.release_group_gid_redirect (new_id);

CREATE INDEX track_gid_redirect_idx_new_id ON musicbrainz.track_gid_redirect (new_id);

CREATE UNIQUE INDEX release_group_idx_gid ON musicbrainz.release_group (gid);
CREATE INDEX release_group_idx_name ON musicbrainz.release_group (name);
CREATE INDEX release_group_idx_artist_credit ON musicbrainz.release_group (artist_credit);

CREATE INDEX medium_idx_track_count ON musicbrainz.medium (track_count);

CREATE UNIQUE INDEX medium_format_idx_gid ON musicbrainz.medium_format (gid);

CREATE UNIQUE INDEX release_status_idx_gid ON musicbrainz.release_status (gid);

CREATE UNIQUE INDEX language_idx_iso_code_2b ON musicbrainz.language (iso_code_2b);
CREATE UNIQUE INDEX language_idx_iso_code_2t ON musicbrainz.language (iso_code_2t);
CREATE UNIQUE INDEX language_idx_iso_code_1 ON musicbrainz.language (iso_code_1);
CREATE UNIQUE INDEX language_idx_iso_code_3 ON musicbrainz.language (iso_code_3);

CREATE UNIQUE INDEX release_packaging_idx_gid ON musicbrainz.release_packaging (gid);

CREATE UNIQUE INDEX script_idx_iso_code ON musicbrainz.script (iso_code);

CREATE UNIQUE INDEX gender_idx_gid ON musicbrainz.gender (gid);

CREATE UNIQUE INDEX artist_type_idx_gid ON musicbrainz.artist_type (gid);

COMMIT;
27 changes: 27 additions & 0 deletions admin/sql/create_musicbrainz_primary_keys.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
BEGIN;

ALTER TABLE musicbrainz.artist ADD CONSTRAINT artist_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.artist_credit ADD CONSTRAINT artist_credit_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.artist_credit_name ADD CONSTRAINT artist_credit_name_pkey PRIMARY KEY (artist_credit, position);
ALTER TABLE musicbrainz.artist_gid_redirect ADD CONSTRAINT artist_gid_redirect_pkey PRIMARY KEY (gid);
ALTER TABLE musicbrainz.area ADD CONSTRAINT area_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.area_type ADD CONSTRAINT area_type_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.recording ADD CONSTRAINT recording_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.recording_gid_redirect ADD CONSTRAINT recording_gid_redirect_pkey PRIMARY KEY (gid);
ALTER TABLE musicbrainz.release ADD CONSTRAINT release_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.release_gid_redirect ADD CONSTRAINT release_gid_redirect_pkey PRIMARY KEY (gid);
ALTER TABLE musicbrainz.track ADD CONSTRAINT track_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.track_gid_redirect ADD CONSTRAINT track_gid_redirect_pkey PRIMARY KEY (gid);
ALTER TABLE musicbrainz.release_group ADD CONSTRAINT release_group_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.release_group_gid_redirect ADD CONSTRAINT release_group_gid_redirect_pkey PRIMARY KEY (gid);
ALTER TABLE musicbrainz.medium ADD CONSTRAINT medium_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.medium_format ADD CONSTRAINT medium_format_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.release_status ADD CONSTRAINT release_status_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.release_group_primary_type ADD CONSTRAINT release_group_primary_type_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.language ADD CONSTRAINT language_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.release_packaging ADD CONSTRAINT release_packaging_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.script ADD CONSTRAINT script_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.gender ADD CONSTRAINT gender_pkey PRIMARY KEY (id);
ALTER TABLE musicbrainz.artist_type ADD CONSTRAINT artist_type_pkey PRIMARY KEY (id);

COMMIT;
7 changes: 7 additions & 0 deletions admin/sql/create_musicbrainz_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Create the musicbrainz schema.

BEGIN;

CREATE SCHEMA IF NOT EXISTS musicbrainz;

COMMIT;
Loading