summaryrefslogtreecommitdiff
path: root/init.postgresql.sql
blob: 96ddca5a5fcb0ff4821bd88b4fd74a84a254249d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
BEGIN;

CREATE SEQUENCE artists_id_seq;
CREATE TABLE artists (
	id INTEGER PRIMARY KEY DEFAULT nextval('artists_id_seq'),
	name VARCHAR UNIQUE);
ALTER SEQUENCE artists_id_seq OWNED BY artists.id;

CREATE SEQUENCE albums_id_seq;
CREATE TABLE albums (
	id INTEGER PRIMARY KEY DEFAULT nextval('albums_id_seq'),
	artist_id INTEGER REFERENCES artists (id) NULL,
	name VARCHAR,
	tracks INTEGER,
	UNIQUE(artist_id, name));
ALTER SEQUENCE albums_id_seq OWNED BY albums.id;

CREATE SEQUENCE tracks_id_seq;
CREATE TABLE tracks (
	id INTEGER PRIMARY KEY DEFAULT nextval('tracks_id_seq'),
	artist_id INTEGER REFERENCES artists (id) NULL,
	album_id INTEGER REFERENCES albums (id) NULL,
	name VARCHAR,
	length INTEGER,
	num INTEGER,
	file_name VARCHAR,
	file_index INTEGER,
	UNIQUE(artist_id, name));
ALTER SEQUENCE tracks_id_seq OWNED BY tracks.id;

COMMIT;