--
-- PostgreSQL database dump
--

-- Dumped from database version 9.3.25
-- Dumped by pg_dump version 12.5 (Ubuntu 12.5-0ubuntu0.20.04.1)

SET statement_timeout = 0;
SET lock_timeout = 0;
-- SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
-- SET row_security = off;

--
-- Name: pgmigrate; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA pgmigrate;


--
-- Name: tiger; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA tiger;


--
-- Name: topology; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA topology;


--
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public;


--
-- Name: EXTENSION fuzzystrmatch; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION fuzzystrmatch IS 'determine similarities and distance between strings';


--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;


--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';


--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;


--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';


--
-- Name: bootstrap_pg_migrate(); Type: FUNCTION; Schema: pgmigrate; Owner: -
--

CREATE FUNCTION pgmigrate.bootstrap_pg_migrate() RETURNS void
    LANGUAGE plpgsql
    AS $$ DECLARE found_pg_migrate information_schema.tables; found_pg_migrations information_schema.tables; BEGIN BEGIN SELECT * INTO STRICT found_pg_migrate FROM information_schema.tables WHERE table_name = 'pg_migrate' and table_schema = 'pgmigrate'; EXCEPTION WHEN NO_DATA_FOUND THEN CREATE TABLE pgmigrate.pg_migrate (id BIGSERIAL PRIMARY KEY, template_version VARCHAR(255), builder_version VARCHAR(255), migrator_version VARCHAR(255), database_version VARCHAR(1024)); CREATE INDEX pg_migrate_unique_index ON pgmigrate.pg_migrate (template_version, builder_version, migrator_version, database_version); WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'Multiple pg_migrate tables.  Unique key on information_schema.tables should have prevented this.'; END; BEGIN SELECT * INTO STRICT found_pg_migrations FROM information_schema.tables WHERE table_name = 'pg_migrations' and table_schema = 'pgmigrate'; EXCEPTION WHEN NO_DATA_FOUND THEN CREATE TABLE pgmigrate.pg_migrations( name VARCHAR(255) PRIMARY KEY, ordinal INTEGER NOT NULL, created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, finalized SMALLINT DEFAULT 1, pg_migrate_id BIGINT NOT NULL REFERENCES pgmigrate.pg_migrate(id)); WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'Multiple pg_migrations tables.  Unique key on information_schema.tables should have prevented this.'; END; END; $$;


--
-- Name: bypass_existing_migration(character varying); Type: FUNCTION; Schema: pgmigrate; Owner: -
--

CREATE FUNCTION pgmigrate.bypass_existing_migration(migration character varying) RETURNS void
    LANGUAGE plpgsql
    AS $_$ DECLARE found_migration pgmigrate.pg_migrations; BEGIN BEGIN EXECUTE 'SELECT * FROM pgmigrate.pg_migrations WHERE name=$1' INTO STRICT found_migration USING migration ; EXCEPTION WHEN NO_DATA_FOUND THEN RETURN; WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'pg_migrate: code=pg_migrations_uniqueness_error, migration=%', migration; END; RAISE EXCEPTION 'pg_migrate: code=migration_exists, migration=%', migration; END; $_$;


--
-- Name: record_migration(character varying, integer, character varying, character varying); Type: FUNCTION; Schema: pgmigrate; Owner: -
--

CREATE FUNCTION pgmigrate.record_migration(migration character varying, ordinal integer, template_version character varying, builder_version character varying) RETURNS void
    LANGUAGE plpgsql
    AS $_$ DECLARE found_pg_migrate_id BIGINT; migrator_version VARCHAR(255); BEGIN EXECUTE 'SELECT current_setting(''application_name'')' INTO migrator_version; BEGIN EXECUTE 'SELECT id FROM pgmigrate.pg_migrate WHERE template_version=$1 and builder_version=$2 and migrator_version=$3 and database_version=$4' INTO found_pg_migrate_id USING template_version, builder_version, migrator_version, (select version()); EXCEPTION WHEN NO_DATA_FOUND THEN found_pg_migrate_id = NULL; WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'pg_migrate: code=pg_migrate_uniqueness_error, migration=%, ordinal=%, template_version=%, builder_version=%, migrator_version=%, database_version=%', migration, ordinal, template_version, builder_version, migrator_version, (select version()); END; IF found_pg_migrate_id IS NULL THEN INSERT INTO pgmigrate.pg_migrate(id, template_version, builder_version, migrator_version, database_version) VALUES (default, template_version, builder_version, migrator_version, (select version())) RETURNING id INTO found_pg_migrate_id; END IF; EXECUTE 'INSERT INTO pgmigrate.pg_migrations(name, ordinal, created, finalized, pg_migrate_id) VALUES ($1, $2, CURRENT_TIMESTAMP, 1, $3)' USING migration, ordinal, found_pg_migrate_id; END; $_$;


--
-- Name: verify_against_existing_migrations(character varying, integer); Type: FUNCTION; Schema: pgmigrate; Owner: -
--

CREATE FUNCTION pgmigrate.verify_against_existing_migrations(migration character varying, ordinal integer) RETURNS void
    LANGUAGE plpgsql
    AS $_$ DECLARE found_migration pgmigrate.pg_migrations; BEGIN BEGIN EXECUTE 'SELECT * FROM pgmigrate.pg_migrations WHERE name=$1' INTO STRICT found_migration USING migration; EXCEPTION WHEN NO_DATA_FOUND THEN IF coalesce((SELECT MAX(p.ordinal) FROM pgmigrate.pg_migrations as p), -1) <> ordinal - 1 THEN RAISE EXCEPTION 'pg_migrate: code=missing_migration, migration=%, ordinal=%, last_ordinal=%', migration, ordinal, (SELECT MAX(p.ordinal) FROM pgmigrate.pg_migrations as p); END IF; RETURN; WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'pg_migrate: code=pg_migrations_uniqueness_error, migration=%', migration; END; IF found_migration.ordinal <> ordinal THEN RAISE EXCEPTION 'pg_migrate: code=incorrect_ordinal, migration=%, expected_ordinal=%, actual_ordinal=%', migration, ordinal, found_migration.ordinal; END IF; END; $_$;


--
-- Name: verify_manifest_is_not_old(integer); Type: FUNCTION; Schema: pgmigrate; Owner: -
--

CREATE FUNCTION pgmigrate.verify_manifest_is_not_old(manifest_version integer) RETURNS void
    LANGUAGE plpgsql
    AS $$ DECLARE max_ordinal INTEGER; BEGIN EXECUTE 'SELECT max(ordinal) FROM pgmigrate.pg_migrations' INTO max_ordinal; IF max_ordinal > manifest_version THEN RAISE EXCEPTION 'pg_migrate: code=old_manifest, max_ordinal_in_db=%, manifest_version=%', max_ordinal, manifest_version; END IF; END; $$;


--
-- Name: _final_median(numeric[]); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public._final_median(numeric[]) RETURNS numeric
    LANGUAGE sql
    AS $_$ SELECT AVG(val) FROM ( SELECT val FROM unnest($1) val ORDER BY 1 LIMIT  2 - MOD(array_upper($1, 1), 2) OFFSET CEIL(array_upper($1, 1) / 2.0) - 1 ) sub; $_$;


--
-- Name: ams_index(character varying, bigint, integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.ams_index(my_user_id character varying, my_locidispid bigint, my_audio_latency integer) RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN CREATE TEMPORARY TABLE ams_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; INSERT INTO ams_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM active_music_sessions; UPDATE ams_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE q.music_session_id = s.music_session_id AND s.id = rrs.rsvp_slot_id AND rrs.rsvp_request_id = r.id AND r.user_id = my_user_id AND rrs.chosen = TRUE AND q.tag is NULL; UPDATE ams_music_session_tmp q SET tag = 2 FROM invitations i WHERE q.music_session_id = i.music_session_id AND i.receiver_id = my_user_id AND q.tag IS NULL; UPDATE ams_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE q.music_session_id = m.id AND m.musician_access = TRUE AND q.tag IS NULL; DELETE FROM ams_music_session_tmp WHERE tag IS NULL; CREATE TEMPORARY TABLE ams_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, full_score INTEGER, audio_latency INTEGER, internet_score INTEGER) ON COMMIT DROP; IF my_audio_latency > -1 THEN INSERT INTO ams_users_tmp SELECT DISTINCT c.music_session_id, c.user_id, s.full_score AS full_score, s.a_audio_latency, s.score FROM ams_music_session_tmp q INNER JOIN connections c ON c.music_session_id = q.music_session_id LEFT OUTER JOIN current_scores s ON s.a_userid = c.user_id WHERE s.b_userid = my_user_id; INSERT INTO ams_users_tmp SELECT NULL, users.id, s.full_score AS full_score, s.a_audio_latency, s.score FROM ams_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id LEFT OUTER JOIN current_scores s    ON s.a_userid = users.id WHERE s.b_userid = my_user_id AND rsvp_requests_rsvp_slots.chosen = TRUE AND users.id NOT IN (SELECT user_id FROM ams_users_tmp); END IF; UPDATE ams_music_session_tmp q SET latency = (select AVG(u.full_score) FROM ams_users_tmp u WHERE q.music_session_id = u.music_session_id); RETURN; END; $$;


--
-- Name: bootstrap_users(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.bootstrap_users() RETURNS void
    LANGUAGE plpgsql
    AS $_$ DECLARE test_user VARCHAR(64); BEGIN SELECT id INTO STRICT test_user FROM users WHERE id = '1'; UPDATE users SET first_name = 'Test', last_name = 'User', email = 'test@jamkazam.com', remember_token = 'NQubl-z16Em94tnSdofObw', password_digest = '$2a$10$QyaNTLVX5DAaJ.JL21kDWeUQqdh3Qh7JQbdRgE82x1Cib7HWNcHXC', email_confirmed=true, musician=true WHERE id = '1'; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO users (id, first_name, last_name, email, remember_token, password_digest, email_confirmed, musician) VALUES ('1', 'Test', 'User', 'test@jamkazam.com', 'NQubl-z16Em94tnSdofObw', '$2a$10$QyaNTLVX5DAaJ.JL21kDWeUQqdh3Qh7JQbdRgE82x1Cib7HWNcHXC', true, true); RETURN; WHEN TOO_MANY_ROWS THEN RAISE EXCEPTION 'user id 1 not unique'; END; $_$;


--
-- Name: connection_failed_score(character varying, character varying, interval, integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.connection_failed_score(a_client_id character varying, b_client_id character varying, timeout_time interval, failed_score_threshold integer) RETURNS boolean
    LANGUAGE plpgsql
    AS $$ DECLARE ret BOOLEAN; BEGIN UPDATE connections SET scoring_timeout_occurrences = CASE WHEN scoring_failures = scoring_failures_offset + failed_score_threshold - 1 THEN scoring_timeout_occurrences + 1 ELSE scoring_timeout_occurrences END, scoring_timeout             = CASE WHEN scoring_failures = scoring_failures_offset + failed_score_threshold - 1 THEN CURRENT_TIMESTAMP + timeout_time ELSE scoring_timeout END, scoring_failures_offset     = CASE WHEN scoring_failures = scoring_failures_offset + failed_score_threshold - 1 THEN scoring_failures + 1 WHEN scoring_timeout < CURRENT_TIMESTAMP THEN scoring_failures_offset ELSE scoring_failures_offset + 1 END, scoring_failures            = scoring_failures + 1 WHERE connections.client_id = b_client_id; UPDATE connections SET scoring_timeout_occurrences = CASE WHEN scoring_failures = scoring_failures_offset + failed_score_threshold - 1 THEN scoring_timeout_occurrences + 1 ELSE scoring_timeout_occurrences END, scoring_timeout             = CASE WHEN scoring_failures = scoring_failures_offset + failed_score_threshold - 1 THEN CURRENT_TIMESTAMP + timeout_time ELSE scoring_timeout END, scoring_failures_offset     = CASE WHEN scoring_failures = scoring_failures_offset + failed_score_threshold - 1 THEN scoring_failures + 1 WHEN scoring_timeout < CURRENT_TIMESTAMP THEN scoring_failures_offset ELSE scoring_failures_offset + 1 END, scoring_failures            = scoring_failures + 1 WHERE connections.client_id = a_client_id RETURNING scoring_timeout > NOW() AS in_timeout INTO ret; RETURN ret; END; $$;


--
-- Name: connection_good_score(character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.connection_good_score(a_client_id character varying, b_client_id character varying) RETURNS boolean
    LANGUAGE plpgsql
    AS $$ DECLARE ret BOOLEAN; BEGIN UPDATE connections SET scoring_failures             = CASE WHEN scoring_timeout < CURRENT_TIMESTAMP THEN 0 ELSE scoring_failures END, scoring_failures_offset       = CASE WHEN scoring_timeout < CURRENT_TIMESTAMP THEN 0 ELSE scoring_failures_offset END WHERE connections.client_id = b_client_id; UPDATE connections SET scoring_failures             = CASE WHEN scoring_timeout < CURRENT_TIMESTAMP THEN 0 ELSE scoring_failures END, scoring_failures_offset       = CASE WHEN scoring_timeout < CURRENT_TIMESTAMP THEN 0 ELSE scoring_failures_offset END WHERE connections.client_id = a_client_id RETURNING scoring_timeout > NOW() AS in_timeout INTO ret; RETURN ret; END; $$;


--
-- Name: discard_scores(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.discard_scores(keep integer) RETURNS void
    LANGUAGE plpgsql
    AS $$ BEGIN DELETE FROM scores WHERE score_dt < (SELECT score_dt FROM scores s WHERE s.alocidispid = scores.alocidispid AND s.blocidispid = scores.blocidispid ORDER BY score_dt DESC LIMIT 1 OFFSET (keep - 1)); RETURN; END; $$;


--
-- Name: generate_scores_dataset(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.generate_scores_dataset() RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN delete from GeoIPLocations; insert into GeoIPLocations (locId, countryCode, region, city, postalCode, latitude, longitude, metroCode, areaCode) values (17192,'US','TX','Austin','78749',30.2076,-97.8587,635,'512'), (667,'US','TX','Dallas','75207',32.7825,-96.8207,623,'214'), (30350,'US','TX','Houston','77001',29.7633,-95.3633,618,'713'), (31423,'US','CO','Denver','80201',39.7392,-104.9847,751,'303'), (1807,'US','TX','San Antonio','78201',29.4713,-98.5353,641,'210'), (23565,'US','FL','Miami','33101',25.7743,-80.1937,528,'305'), (11704,'US','FL','Tampa','33601',27.9475,-82.4584,539,'813'), (26424,'US','MA','Boston','02101',42.3584,-71.0598,506,'617'), (5059,'US','ME','Portland','04101',43.6589,-70.2615,500,'207'), (2739,'US','OR','Portland','97201',45.5073,-122.6932,820,'503'), (1539,'US','WA','Seattle','98101',47.6103,-122.3341,819,'206'), (2720,'US','CA','Mountain View','94040',37.3845,-122.0881,807,'650'), (154078,'US','AR','Mountain View','72560',35.8732,-92.0717,693,'870'), (3964,'US','CA','Barstow','92311',34.9701,-116.9929,803,'760'), (14447,'US','OK','Tulsa','74101',36.154,-95.9928,671,'918'), (162129,'US','TN','Memphis','37501',35.1693,-89.9904,640,'713'); delete from GeoIPBlocks; insert into GeoIPBlocks (beginIp, endIp, locId) values (x'00000000'::bigint,x'0FFFFFFF'::bigint,17192), (x'10000000'::bigint,x'1FFFFFFF'::bigint,667), (x'20000000'::bigint,x'2FFFFFFF'::bigint,30350), (x'30000000'::bigint,x'3FFFFFFF'::bigint,31423), (x'40000000'::bigint,x'4FFFFFFF'::bigint,1807), (x'50000000'::bigint,x'5FFFFFFF'::bigint,23565), (x'60000000'::bigint,x'6FFFFFFF'::bigint,11704), (x'70000000'::bigint,x'7FFFFFFF'::bigint,26424), (x'80000000'::bigint,x'8FFFFFFF'::bigint,5059), (x'90000000'::bigint,x'9FFFFFFF'::bigint,2739), (x'A0000000'::bigint,x'AFFFFFFF'::bigint,1539), (x'B0000000'::bigint,x'BFFFFFFF'::bigint,2720), (x'C0000000'::bigint,x'CFFFFFFF'::bigint,154078), (x'D0000000'::bigint,x'DFFFFFFF'::bigint,3964), (x'E0000000'::bigint,x'EFFFFFFF'::bigint,14447), (x'F0000000'::bigint,x'FFFEFFFF'::bigint,162129); delete from GeoIPISP; insert into GeoIPISP values (x'00000000'::bigint,x'0FFFFFFF'::bigint,'Intergalactic Boogie'), (x'10000000'::bigint,x'1FFFFFFF'::bigint,'Powerful Pipes'), (x'20000000'::bigint,x'2FFFFFFF'::bigint,'Powerful Pipes'), (x'30000000'::bigint,x'3FFFFFFF'::bigint,'Intergalactic Boogie'), (x'40000000'::bigint,x'4FFFFFFF'::bigint,'Tangled Webs'), (x'50000000'::bigint,x'5FFFFFFF'::bigint,'Tangled Webs'), (x'60000000'::bigint,x'6FFFFFFF'::bigint,'Powerful Pipes'), (x'70000000'::bigint,x'7FFFFFFF'::bigint,'Intergalactic Boogie'), (x'80000000'::bigint,x'8FFFFFFF'::bigint,'Greasy Lightning'), (x'90000000'::bigint,x'9FFFFFFF'::bigint,'Powerful Pipes'), (x'A0000000'::bigint,x'AFFFFFFF'::bigint,'Intergalactic Boogie'), (x'B0000000'::bigint,x'BFFFFFFF'::bigint,'Tangled Webs'), (x'C0000000'::bigint,x'CFFFFFFF'::bigint,'Greasy Lightning'), (x'D0000000'::bigint,x'DFFFFFFF'::bigint,'Tangled Webs'), (x'E0000000'::bigint,x'EFFFFFFF'::bigint,'Intergalactic Boogie'), (x'F0000000'::bigint,x'FFFEFFFF'::bigint,'Powerful Pipes'); DELETE FROM jamcompany; ALTER SEQUENCE jamcompany_coid_seq RESTART WITH 1; INSERT INTO jamcompany (company) SELECT DISTINCT company FROM geoipisp ORDER BY company; DELETE FROM jamisp; INSERT INTO jamisp (beginip, endip, coid) SELECT x.beginip, x.endip, y.coid FROM geoipisp x, jamcompany y WHERE x.company = y.company; IF EXISTS( SELECT * FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'cities') THEN DELETE FROM cities; INSERT INTO cities (city, region, countrycode) select distinct city, region, countrycode from geoiplocations where length(city) > 0 and length(countrycode) > 0; DELETE FROM regions; INSERT INTO regions (region, regionname, countrycode) select distinct region, region, countrycode from cities; DELETE FROM countries; INSERT INTO countries (countrycode, countryname) select distinct countrycode, countrycode from regions; END IF; RETURN; END; $$;


--
-- Name: get_work(bigint, bigint); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.get_work(mylocidispid bigint, myaddr bigint) RETURNS TABLE(client_id character varying)
    LANGUAGE plpgsql ROWS 5
    AS $$ BEGIN CREATE TEMPORARY TABLE foo (locidispid BIGINT, locid INT); INSERT INTO foo SELECT DISTINCT locidispid, locidispid/1000000 FROM connections WHERE client_type = 'client'; DELETE FROM foo WHERE locidispid IN (SELECT DISTINCT blocidispid FROM most_recent_scores WHERE alocidispid = mylocidispid AND (current_timestamp - score_dt) < INTERVAL '24 hours'); DELETE FROM foo WHERE locid NOT IN (SELECT locid FROM geoiplocations WHERE geog && st_buffer((SELECT geog FROM geoiplocations WHERE locid = mylocidispid/1000000), 4023360)); CREATE TEMPORARY TABLE bar (client_id VARCHAR(64), locidispid BIGINT, r DOUBLE PRECISION); INSERT INTO bar SELECT l.client_id, l.locidispid, random() FROM connections l, foo f WHERE l.locidispid = f.locidispid AND l.client_type = 'client' AND addr != myaddr; DROP TABLE foo; DELETE FROM bar b WHERE r != (SELECT MAX(r) FROM bar b0 WHERE b0.locidispid = b.locidispid); RETURN QUERY SELECT b.client_id FROM bar b ORDER BY r LIMIT 5; DROP TABLE bar; RETURN; END; $$;


--
-- Name: get_work(character varying, bigint, bigint, integer, interval); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.get_work(my_client_id character varying, mylocidispid bigint, myaddr bigint, return_rows integer, stale_score interval) RETURNS TABLE(client_id character varying)
    LANGUAGE plpgsql
    AS $$ BEGIN RETURN QUERY WITH scorable_locations AS ( SELECT DISTINCT locidispid FROM connections WHERE client_type = 'client' AND connections.client_id != my_client_id AND addr != myaddr AND udp_reachable AND is_network_testing = FALSE AND NOW() > scoring_timeout AND connections.music_session_id IS NULL AND locidispid NOT IN (SELECT DISTINCT blocidispid FROM most_recent_scores WHERE alocidispid = mylocidispid AND (current_timestamp - score_dt) < stale_score) AND locidispid/1000000 IN (SELECT locid FROM geoiplocations WHERE geog && st_buffer((SELECT geog FROM geoiplocations WHERE locid = mylocidispid/1000000), 4023360)) ) SELECT tmp.client_id FROM (SELECT connections.client_id, random() AS r, row_number() OVER (PARTITION BY connections.locidispid) AS rownum FROM connections, scorable_locations WHERE connections.locidispid = scorable_locations.locidispid AND client_type = 'client' AND connections.client_id != my_client_id AND  addr != myaddr AND udp_reachable AND NOW() > scoring_timeout AND connections.music_session_id IS NULL ) tmp WHERE rownum <= 1 ORDER BY r LIMIT return_rows; RETURN; END; $$;


--
-- Name: get_work_summary(interval); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.get_work_summary(stale_score interval) RETURNS TABLE(work_count bigint, client_id character varying, email character varying, first_name character varying, last_name character varying, user_id character varying, udp_reachable boolean, in_timeout boolean, in_session boolean, scoring_failures integer, scoring_failures_offset integer, scoring_timeout_occurrences integer, is_network_testing boolean)
    LANGUAGE plpgsql
    AS $$ BEGIN RETURN QUERY SELECT SUM(CASE WHEN tmp.test_client_id IS NULL OR tmp.in_session OR tmp.in_timeout OR tmp.udp_reachable = FALSE OR tmp.is_network_testing = TRUE THEN 0 ELSE 1 END) AS work_count, tmp.client_id AS client_id, users.email, users.first_name, users.last_name, users.id AS user_id, tmp.udp_reachable, tmp.in_timeout, tmp.in_session, tmp.scoring_failures, tmp.scoring_failures_offset, tmp.scoring_timeout_occurrences, tmp.is_network_testing FROM (SELECT connections.client_type, scorable_locations.client_id AS test_client_id, connections.client_id AS client_id, connections.user_id AS user_id, connections.udp_reachable, connections.scoring_timeout > NOW() as in_timeout, connections.music_session_id IS NOT NULL AS in_session, connections.scoring_failures, connections.scoring_failures_offset, connections.scoring_timeout_occurrences, connections.is_network_testing, scorable_locations.client_id IS NULL AS same_client, row_number() OVER (PARTITION BY connections.locidispid) AS rownum FROM connections LEFT OUTER JOIN scorable_locations(connections.client_id, connections.locidispid, connections.addr, stale_score) ON connections.locidispid != scorable_locations.locidispid) tmp INNER JOIN users ON tmp.user_id = users.id WHERE tmp.client_type = 'client' GROUP BY tmp.client_id, users.email, users.first_name, users.last_name, users.id, tmp.same_client, tmp.udp_reachable, tmp.in_timeout, tmp.in_session, tmp.scoring_failures, tmp.scoring_failures_offset, tmp.scoring_timeout_occurrences, tmp.is_network_testing ORDER BY work_count DESC; RETURN; END; $$;


--
-- Name: get_work_summary_no_agg(interval); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.get_work_summary_no_agg(stale_score interval) RETURNS TABLE(client_id character varying, test_client_id character varying, email character varying, first_name character varying, last_name character varying, user_id character varying, udp_reachable boolean, in_timeout boolean, scoring_failures integer, scoring_failures_offset integer, scoring_timeout_occurrences integer, is_network_testing boolean)
    LANGUAGE plpgsql
    AS $$ BEGIN RETURN QUERY SELECT tmp.client_id AS client_id, tmp.test_client_id, users.email, users.first_name, users.last_name, users.id AS user_id, tmp.udp_reachable, tmp.in_timeout, tmp.scoring_failures, tmp.scoring_failures_offset, tmp.scoring_timeout_occurrences, tmp.is_network_testing FROM (SELECT scorable_locations.client_id AS test_client_id, connections.client_id AS client_id, connections.user_id AS user_id, connections.udp_reachable, connections.scoring_timeout > NOW() as in_timeout, connections.scoring_failures, connections.scoring_failures_offset, connections.scoring_timeout_occurrences, connections.is_network_testing, scorable_locations.client_id IS NULL AS same_client, row_number() OVER (PARTITION BY connections.locidispid) AS rownum FROM connections LEFT OUTER JOIN scorable_locations(connections.client_id, connections.locidispid, connections.addr, stale_score) ON connections.locidispid != scorable_locations.locidispid AND connections.client_type = 'client') tmp INNER JOIN users ON tmp.user_id = users.id  ORDER BY tmp.client_id; RETURN; END; $$;


--
-- Name: jam_tracks_update_tsv(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.jam_tracks_update_tsv() RETURNS trigger
    LANGUAGE plpgsql
    AS $$ BEGIN new.search_tsv = to_tsvector('public.jamenglish', COALESCE(NEW.original_artist, '') || ' ' ||  COALESCE(NEW.name, '') || ' ' || COALESCE(NEW.additional_info, '')); new.artist_tsv = to_tsvector('public.jamenglish', COALESCE(NEW.original_artist, '')); new.name_tsv = to_tsvector('public.jamenglish', COALESCE(NEW.name, '')); RETURN NEW; END $$;


--
-- Name: manage_user_online(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.manage_user_online() RETURNS trigger
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN IF (TG_OP = 'DELETE') THEN UPDATE users set ONLINE = (SELECT COUNT(conn.id) FROM connections conn WHERE conn.user_id = OLD.user_id) > 0 WHERE users.id = OLD.user_id; RETURN NULL; ELSIF (TG_OP = 'INSERT') THEN UPDATE users set ONLINE = (SELECT COUNT(conn.id) FROM connections conn WHERE conn.user_id = NEW.user_id) > 0 WHERE users.id = NEW.user_id; RETURN NULL; END IF; RETURN NULL; END; $$;


--
-- Name: phantom_check(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.phantom_check() RETURNS trigger
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN NEW.phantom := (SELECT NEW.email ilike 'phantom+%@jamkazam.com'); RETURN NEW; END; $$;


--
-- Name: populate_current_network_scores(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.populate_current_network_scores() RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ DECLARE r RECORD; BEGIN FOR r IN SELECT DISTINCT alocidispid, blocidispid FROM scores WHERE alocidispid <= blocidispid ORDER BY alocidispid, blocidispid LOOP PERFORM update_current_network_scores(r.alocidispid, r.blocidispid); END LOOP; END; $$;


--
-- Name: scorable_locations(character varying, bigint, bigint, interval); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.scorable_locations(my_client_id character varying, mylocidispid bigint, myaddr bigint, stale_score interval) RETURNS TABLE(locidispid bigint, addr bigint, client_id character varying)
    LANGUAGE plpgsql
    AS $$ BEGIN RETURN QUERY SELECT c.locidispid, c.addr, c.client_id FROM connections c WHERE client_type = 'client' AND c.udp_reachable AND NOW() > c.scoring_timeout AND c.music_session_id IS NULL AND c.addr != myaddr AND c.client_id != my_client_id AND c.locidispid NOT IN (SELECT DISTINCT blocidispid FROM most_recent_scores WHERE alocidispid = mylocidispid AND (current_timestamp - score_dt) < stale_score) AND c.locidispid/1000000 IN (SELECT locid FROM geoiplocations WHERE geog && st_buffer((SELECT geog FROM geoiplocations WHERE locid = mylocidispid/1000000), 4023360)); RETURN; END; $$;


--
-- Name: sms_index(character varying, bigint, integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.sms_index(my_user_id character varying, my_locidispid bigint, my_audio_latency integer) RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN CREATE TEMPORARY TABLE sms_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  (scheduled_start IS NULL OR scheduled_start > (NOW() - (interval '15 minute'))) AND canceled = FALSE AND id NOT IN (SELECT id FROM active_music_sessions); UPDATE sms_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE q.music_session_id = s.music_session_id AND s.id = rrs.rsvp_slot_id AND rrs.rsvp_request_id = r.id AND r.user_id = my_user_id AND rrs.chosen = TRUE AND q.tag is NULL; UPDATE sms_music_session_tmp q SET tag = 2 FROM invitations i WHERE q.music_session_id = i.music_session_id AND i.receiver_id = my_user_id AND q.tag IS NULL; UPDATE sms_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE q.music_session_id = m.id AND m.open_rsvps = TRUE AND q.tag IS NULL; DELETE FROM sms_music_session_tmp WHERE tag IS NULL; CREATE TEMPORARY TABLE sms_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, latency INTEGER) ON COMMIT DROP; IF my_audio_latency > -1 THEN INSERT INTO sms_users_tmp SELECT q.music_session_id, users.id, s.full_score/2 AS latency FROM sms_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id LEFT OUTER JOIN current_scores s    ON s.alocidispid = users.last_jam_locidispid WHERE s.blocidispid = my_locidispid AND rsvp_requests_rsvp_slots.chosen = TRUE; INSERT INTO sms_users_tmp SELECT NULL, users.id, s.full_score/2 AS latency FROM sms_music_session_tmp q INNER JOIN invitations              ON invitations.music_session_id = q.music_session_id INNER JOIN users                    ON invitations.receiver_id = users.id LEFT OUTER JOIN current_scores s    ON s.alocidispid = users.last_jam_locidispid WHERE s.blocidispid = my_locidispid AND users.id NOT IN (SELECT user_id FROM sms_users_tmp); END IF; UPDATE sms_music_session_tmp q SET latency = (select AVG(u.latency) FROM sms_users_tmp u WHERE q.music_session_id = u.music_session_id); RETURN; END; $$;


--
-- Name: sms_index(character varying, bigint, integer, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.sms_index(my_user_id character varying, my_locidispid bigint, my_audio_latency integer, session_id character varying) RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN CREATE TEMPORARY TABLE sms_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; IF session_id = 'any' THEN INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  (scheduled_start IS NULL OR scheduled_start > (NOW() - (interval '15 minute'))) AND canceled = FALSE AND id NOT IN (SELECT id FROM active_music_sessions); UPDATE sms_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE q.music_session_id = s.music_session_id AND s.id = rrs.rsvp_slot_id AND rrs.rsvp_request_id = r.id AND r.user_id = my_user_id AND rrs.chosen = TRUE AND q.tag is NULL; UPDATE sms_music_session_tmp q SET tag = 2 FROM invitations i WHERE q.music_session_id = i.music_session_id AND i.receiver_id = my_user_id AND q.tag IS NULL; UPDATE sms_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE q.music_session_id = m.id AND m.open_rsvps = TRUE AND q.tag IS NULL; DELETE FROM sms_music_session_tmp WHERE tag IS NULL; ELSE INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  music_sessions.id = session_id; END IF; CREATE TEMPORARY TABLE sms_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, full_score INTEGER, audio_latency INTEGER, internet_score INTEGER) ON COMMIT DROP; IF my_audio_latency > -1 THEN INSERT INTO sms_users_tmp SELECT DISTINCT q.music_session_id, users.id, s.full_score AS full_score, s.a_audio_latency, s.score FROM sms_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id LEFT OUTER JOIN current_scores s    ON s.a_userid = users.id WHERE s.b_userid = my_user_id AND rsvp_requests_rsvp_slots.chosen = TRUE AND rsvp_requests.canceled != TRUE; END IF; UPDATE sms_music_session_tmp q SET latency = (select AVG(u.full_score) FROM sms_users_tmp u WHERE q.music_session_id = u.music_session_id); RETURN; END; $$;


--
-- Name: sms_index(character varying, bigint, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.sms_index(my_user_id character varying, my_locidispid bigint, my_audio_latency integer, session_id character varying, include_pending boolean DEFAULT false) RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN CREATE TEMPORARY TABLE sms_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; IF session_id = 'any' THEN INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  old = FALSE AND (scheduled_start IS NULL OR scheduled_start > (NOW() - (interval '15 minute'))) AND canceled = FALSE AND description != 'Jam Track Session' AND id NOT IN (SELECT id FROM active_music_sessions); UPDATE sms_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE q.music_session_id = s.music_session_id AND s.id = rrs.rsvp_slot_id AND rrs.rsvp_request_id = r.id AND r.user_id = my_user_id AND rrs.chosen = TRUE AND q.tag is NULL; UPDATE sms_music_session_tmp q SET tag = 2 FROM invitations i WHERE q.music_session_id = i.music_session_id AND i.receiver_id = my_user_id AND q.tag IS NULL; UPDATE sms_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE q.music_session_id = m.id AND m.open_rsvps = TRUE AND q.tag IS NULL; DELETE FROM sms_music_session_tmp WHERE tag IS NULL; ELSE INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  music_sessions.id = session_id; END IF; CREATE TEMPORARY TABLE sms_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, full_score INTEGER, audio_latency INTEGER, internet_score INTEGER) ON COMMIT DROP; IF my_audio_latency > -1 THEN IF include_pending THEN INSERT INTO sms_users_tmp SELECT DISTINCT q.music_session_id, users.id, s.full_score AS full_score, s.a_audio_latency, s.score FROM sms_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id LEFT OUTER JOIN current_scores s    ON s.a_userid = users.id WHERE s.b_userid = my_user_id; INSERT INTO sms_users_tmp SELECT NULL, users.id, s.full_score AS full_score, s.a_audio_latency, s.score FROM sms_music_session_tmp q INNER JOIN invitations              ON invitations.music_session_id = q.music_session_id INNER JOIN users                    ON invitations.receiver_id = users.id LEFT OUTER JOIN current_scores s    ON s.a_userid = users.id WHERE s.b_userid = my_user_id AND users.id NOT IN (SELECT user_id FROM sms_users_tmp); ELSE INSERT INTO sms_users_tmp SELECT DISTINCT q.music_session_id, users.id, s.full_score AS full_score, s.a_audio_latency, s.score FROM sms_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id LEFT OUTER JOIN current_scores s    ON s.a_userid = users.id WHERE s.b_userid = my_user_id AND rsvp_requests_rsvp_slots.chosen = TRUE AND rsvp_requests.canceled != TRUE; END IF; END IF; UPDATE sms_music_session_tmp q SET latency = (select AVG(u.full_score) FROM sms_users_tmp u WHERE q.music_session_id = u.music_session_id); RETURN; END; $$;


--
-- Name: sms_index_test(character varying, bigint, integer, character varying, boolean); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.sms_index_test(my_user_id character varying, my_locidispid bigint, my_audio_latency integer, session_id character varying, include_pending boolean DEFAULT false) RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ BEGIN CREATE TEMPORARY TABLE sms_music_session_tmp (music_session_id VARCHAR(64) NOT NULL, tag INTEGER, latency INTEGER) ON COMMIT DROP; IF session_id = 'any' THEN INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  (scheduled_start IS NULL OR scheduled_start > (NOW() - (interval '15 minute'))) AND canceled = FALSE AND description != 'Jam Track Session' AND id NOT IN (SELECT id FROM active_music_sessions) ; UPDATE sms_music_session_tmp q SET tag = 1 FROM rsvp_slots s, rsvp_requests_rsvp_slots rrs, rsvp_requests r WHERE q.music_session_id = s.music_session_id AND s.id = rrs.rsvp_slot_id AND rrs.rsvp_request_id = r.id AND r.user_id = my_user_id AND rrs.chosen = TRUE AND q.tag is NULL; UPDATE sms_music_session_tmp q SET tag = 2 FROM invitations i WHERE q.music_session_id = i.music_session_id AND i.receiver_id = my_user_id AND q.tag IS NULL; UPDATE sms_music_session_tmp q SET tag = 3 FROM music_sessions m WHERE q.music_session_id = m.id AND m.open_rsvps = TRUE AND q.tag IS NULL; DELETE FROM sms_music_session_tmp WHERE tag IS NULL; ELSE INSERT INTO sms_music_session_tmp SELECT DISTINCT id, NULL::INTEGER AS tag, NULL::INTEGER AS latency FROM music_sessions WHERE  music_sessions.id = session_id; END IF; CREATE TEMPORARY TABLE sms_users_tmp (music_session_id VARCHAR(64), user_id VARCHAR(64) NOT NULL, full_score INTEGER, audio_latency INTEGER, internet_score INTEGER) ON COMMIT DROP; IF my_audio_latency > -1 THEN IF include_pending THEN INSERT INTO sms_users_tmp SELECT DISTINCT q.music_session_id, users.id, CAST(NULL AS INTEGER), CAST(NULL AS INTEGER), CAST(NULL AS INTEGER) FROM sms_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id; INSERT INTO sms_users_tmp SELECT NULL, users.id, CAST(NULL AS INTEGER), CAST(NULL AS INTEGER), CAST(NULL AS INTEGER) FROM sms_music_session_tmp q INNER JOIN invitations              ON invitations.music_session_id = q.music_session_id INNER JOIN users                    ON invitations.receiver_id = users.id WHERE users.id NOT IN (SELECT user_id FROM sms_users_tmp); ELSE INSERT INTO sms_users_tmp SELECT DISTINCT q.music_session_id, users.id, CAST(NULL AS INTEGER), CAST(NULL AS INTEGER), CAST(NULL AS INTEGER) FROM sms_music_session_tmp q INNER JOIN rsvp_slots               ON rsvp_slots.music_session_id = q.music_session_id INNER JOIN rsvp_requests_rsvp_slots ON rsvp_requests_rsvp_slots.rsvp_slot_id = rsvp_slots.id INNER JOIN rsvp_requests            ON rsvp_requests.id = rsvp_requests_rsvp_slots.rsvp_request_id INNER JOIN users                    ON rsvp_requests.user_id = users.id WHERE rsvp_requests_rsvp_slots.chosen = TRUE AND rsvp_requests.canceled != TRUE; END IF; END IF; RETURN; END; $$;


--
-- Name: truncate_tables(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.truncate_tables() RETURNS void
    LANGUAGE plpgsql
    AS $$ DECLARE statements CURSOR FOR SELECT tablename FROM pg_tables WHERE schemaname = 'public'; BEGIN FOR stmt IN statements LOOP EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; END LOOP; END; $$;


--
-- Name: update_current_network_scores(bigint, bigint); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION public.update_current_network_scores(aloc bigint, bloc bigint) RETURNS void
    LANGUAGE plpgsql STRICT
    AS $$ DECLARE newscore INTEGER; newscore_dt TIMESTAMP; newscore_limited BOOL; sum INTEGER; kount INTEGER; r RECORD; avgscore INTEGER; maxscore INTEGER; minscore INTEGER; BEGIN newscore := NULL; newscore_dt := NULL; newscore_limited := FALSE; sum := 0; kount := 0; FOR r IN SELECT score, score_dt FROM scores WHERE alocidispid = aloc AND blocidispid = bloc ORDER BY score_dt DESC LIMIT 6 LOOP IF newscore IS NULL THEN newscore := r.score; newscore_dt := r.score_dt; ELSE sum := sum + r.score; kount := kount + 1; END IF; END LOOP; IF newscore IS NULL THEN DELETE FROM current_network_scores WHERE alocidispid = aloc AND blocidispid = bloc; IF aloc != bloc THEN DELETE FROM current_network_scores WHERE alocidispid = bloc AND blocidispid = aloc; END IF; END IF; IF kount > 0 THEN avgscore := sum / kount; maxscore := avgscore*6/5; minscore := avgscore*4/5; IF newscore > maxscore THEN newscore := maxscore; newscore_limited := TRUE; ELSEIF newscore < minscore THEN newscore := minscore; newscore_limited := TRUE; END IF; END IF; UPDATE current_network_scores SET score = newscore, limited = newscore_limited, score_dt = newscore_dt WHERE alocidispid = aloc AND blocidispid = bloc; IF NOT FOUND THEN INSERT INTO current_network_scores (alocidispid, blocidispid, score, limited, score_dt) VALUES (aloc, bloc, newscore, newscore_limited, newscore_dt); END IF; IF aloc != bloc THEN UPDATE current_network_scores SET score = newscore, limited = newscore_limited, score_dt = newscore_dt WHERE alocidispid = bloc AND blocidispid = aloc; IF NOT FOUND THEN INSERT INTO current_network_scores (alocidispid, blocidispid, score, limited, score_dt) VALUES (bloc, aloc, newscore, newscore_limited, newscore_dt); END IF; END IF; DELETE FROM scores WHERE alocidispid = aloc AND blocidispid = bloc AND scorer = 0 AND score_dt < (SELECT score_dt FROM scores s WHERE s.alocidispid = aloc AND s.blocidispid = bloc AND s.scorer = 0 ORDER BY score_dt DESC LIMIT 1 OFFSET 4); DELETE FROM scores WHERE alocidispid = bloc AND blocidispid = aloc AND scorer = 1 AND score_dt < (SELECT score_dt FROM scores s WHERE s.alocidispid = bloc AND s.blocidispid = aloc AND s.scorer = 1 ORDER BY score_dt DESC LIMIT 1 OFFSET 4); END; $$;


--
-- Name: median(numeric); Type: AGGREGATE; Schema: public; Owner: -
--

CREATE AGGREGATE public.median(numeric) (
    SFUNC = array_append,
    STYPE = numeric[],
    INITCOND = '{}',
    FINALFUNC = public._final_median
);


--
-- Name: english_stem; Type: TEXT SEARCH DICTIONARY; Schema: public; Owner: -
--

CREATE TEXT SEARCH DICTIONARY public.english_stem (
    TEMPLATE = pg_catalog.snowball,
    language = 'english', stopwords = 'english' );


--
-- Name: jamenglish; Type: TEXT SEARCH CONFIGURATION; Schema: public; Owner: -
--

CREATE TEXT SEARCH CONFIGURATION public.jamenglish (
    PARSER = pg_catalog."default" );

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR asciiword WITH english_stem;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR word WITH english_stem;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR numword WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR host WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR version WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR hword_numpart WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR hword_part WITH english_stem;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR hword_asciipart WITH english_stem;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR numhword WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR asciihword WITH english_stem;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR hword WITH english_stem;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR file WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR "int" WITH simple;

ALTER TEXT SEARCH CONFIGURATION public.jamenglish
    ADD MAPPING FOR uint WITH simple;


SET default_tablespace = '';

--
-- Name: pg_migrate; Type: TABLE; Schema: pgmigrate; Owner: -
--

CREATE TABLE pgmigrate.pg_migrate (
    id bigint NOT NULL,
    template_version character varying(255),
    builder_version character varying(255),
    migrator_version character varying(255),
    database_version character varying(1024)
);


--
-- Name: pg_migrate_id_seq; Type: SEQUENCE; Schema: pgmigrate; Owner: -
--

CREATE SEQUENCE pgmigrate.pg_migrate_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: pg_migrate_id_seq; Type: SEQUENCE OWNED BY; Schema: pgmigrate; Owner: -
--

ALTER SEQUENCE pgmigrate.pg_migrate_id_seq OWNED BY pgmigrate.pg_migrate.id;


--
-- Name: pg_migrations; Type: TABLE; Schema: pgmigrate; Owner: -
--

CREATE TABLE pgmigrate.pg_migrations (
    name character varying(255) NOT NULL,
    ordinal integer NOT NULL,
    created timestamp without time zone DEFAULT now(),
    finalized smallint DEFAULT 1,
    pg_migrate_id bigint NOT NULL
);


--
-- Name: active_admin_comments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.active_admin_comments (
    id integer NOT NULL,
    resource_id character varying(255) NOT NULL,
    resource_type character varying(255) NOT NULL,
    author_id integer,
    author_type character varying(255),
    body text,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    namespace character varying(255)
);


--
-- Name: active_admin_comments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.active_admin_comments_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: active_admin_comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.active_admin_comments_id_seq OWNED BY public.active_admin_comments.id;


--
-- Name: active_music_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.active_music_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    claimed_recording_id character varying(64),
    claimed_recording_initiator_id character varying(64),
    track_changes_counter integer DEFAULT 0,
    jam_track_id character varying(64),
    jam_track_initiator_id character varying(64),
    backing_track_path character varying(1024),
    backing_track_initiator_id character varying(64),
    metronome_active boolean DEFAULT false NOT NULL,
    metronome_initiator_id character varying(64),
    school_id integer,
    is_platform_instructor boolean DEFAULT false NOT NULL
);


--
-- Name: affiliate_distributions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.affiliate_distributions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    affiliate_referral_id integer NOT NULL,
    affiliate_referral_fee_in_cents integer NOT NULL,
    sale_line_item_id character varying(64) NOT NULL,
    affiliate_refunded boolean DEFAULT false NOT NULL,
    affiliate_refunded_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: affiliate_legalese; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.affiliate_legalese (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    legalese text,
    version integer DEFAULT 1 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: affiliate_monthly_payments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.affiliate_monthly_payments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    month integer NOT NULL,
    year integer NOT NULL,
    affiliate_partner_id integer NOT NULL,
    due_amount_in_cents integer DEFAULT 0 NOT NULL,
    closed boolean DEFAULT false NOT NULL,
    jamtracks_sold integer DEFAULT 0 NOT NULL,
    closed_at timestamp without time zone,
    last_updated timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: partner_key_sequence; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.partner_key_sequence
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: affiliate_partners; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.affiliate_partners (
    id integer DEFAULT nextval('public.partner_key_sequence'::regclass) NOT NULL,
    partner_name character varying(1000),
    partner_user_id character varying(64),
    entity_type character varying(64),
    legalese_id character varying(64),
    signed_at timestamp without time zone,
    last_paid_at timestamp without time zone,
    address json DEFAULT '{}'::json NOT NULL,
    tax_identifier character varying(1000),
    referral_user_count integer DEFAULT 0 NOT NULL,
    cumulative_earnings_in_cents integer DEFAULT 0 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    rate numeric(8,2) DEFAULT 0.10,
    lesson_rate numeric(8,2) DEFAULT 0.20 NOT NULL,
    special character varying
);


--
-- Name: affiliate_quarterly_payments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.affiliate_quarterly_payments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    quarter integer NOT NULL,
    year integer NOT NULL,
    affiliate_partner_id integer NOT NULL,
    due_amount_in_cents integer DEFAULT 0 NOT NULL,
    paid boolean DEFAULT false NOT NULL,
    closed boolean DEFAULT false NOT NULL,
    jamtracks_sold integer DEFAULT 0 NOT NULL,
    closed_at timestamp without time zone,
    paid_at timestamp without time zone,
    last_updated timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: affiliate_payments; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.affiliate_payments AS
 SELECT affiliate_monthly_payments.id AS monthly_id,
    NULL::character varying AS quarterly_id,
    affiliate_monthly_payments.affiliate_partner_id,
    affiliate_monthly_payments.due_amount_in_cents,
    affiliate_monthly_payments.jamtracks_sold,
    affiliate_monthly_payments.created_at,
    affiliate_monthly_payments.closed,
    NULL::boolean AS paid,
    affiliate_monthly_payments.year,
    affiliate_monthly_payments.month,
    NULL::integer AS quarter,
    affiliate_monthly_payments.month AS time_sort,
    'monthly'::text AS payment_type
   FROM public.affiliate_monthly_payments
UNION ALL
 SELECT NULL::character varying AS monthly_id,
    affiliate_quarterly_payments.id AS quarterly_id,
    affiliate_quarterly_payments.affiliate_partner_id,
    affiliate_quarterly_payments.due_amount_in_cents,
    affiliate_quarterly_payments.jamtracks_sold,
    affiliate_quarterly_payments.created_at,
    affiliate_quarterly_payments.closed,
    affiliate_quarterly_payments.paid,
    affiliate_quarterly_payments.year,
    NULL::integer AS month,
    affiliate_quarterly_payments.quarter,
    ((affiliate_quarterly_payments.quarter * 3) + 3) AS time_sort,
    'quarterly'::text AS payment_type
   FROM public.affiliate_quarterly_payments;


--
-- Name: affiliate_referral_visits; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.affiliate_referral_visits (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    affiliate_partner_id integer NOT NULL,
    ip_address character varying NOT NULL,
    visited_url character varying,
    referral_url character varying,
    first_visit boolean DEFAULT true NOT NULL,
    user_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: affiliate_traffic_totals; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.affiliate_traffic_totals (
    day date NOT NULL,
    signups integer DEFAULT 0 NOT NULL,
    visits integer DEFAULT 0 NOT NULL,
    affiliate_partner_id integer NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: arses_id_int_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.arses_id_int_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: arses; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.arses (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying(200) NOT NULL,
    active boolean DEFAULT true,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    provider character varying(20) DEFAULT 'gcp'::character varying NOT NULL,
    id_int integer DEFAULT nextval('public.arses_id_int_seq'::regclass) NOT NULL,
    ip character varying(200),
    username character varying(200) DEFAULT 'smoketest'::character varying,
    password character varying(200) DEFAULT 'foolishcharmer'::character varying,
    port integer DEFAULT 3478,
    beta boolean DEFAULT false,
    country character varying(200),
    city character varying(200),
    latitude numeric(15,10),
    longitude numeric(15,10),
    subdivision character varying(200),
    continent character varying(200)
);


--
-- Name: artifact_updates; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.artifact_updates (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    product character varying(255) NOT NULL,
    version character varying(255) NOT NULL,
    uri character varying(2000) NOT NULL,
    sha1 character varying(255) NOT NULL,
    environment character varying(255) DEFAULT 'public'::character varying NOT NULL,
    size integer NOT NULL
);


--
-- Name: backing_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.backing_tracks (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    filename character varying(1024) NOT NULL,
    connection_id character varying(64) NOT NULL,
    client_track_id character varying(64) NOT NULL,
    client_resource_id character varying(100),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: band_invitations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.band_invitations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    band_id character varying(64),
    accepted boolean,
    creator_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: bands; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.bands (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying(1024) NOT NULL,
    website character varying(4000),
    biography character varying(4000) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    city character varying(100),
    state character varying(100),
    country character varying(100),
    photo_url character varying(2048),
    logo_url character varying(2048),
    name_tsv tsvector,
    original_fpfile_photo character varying(8000) DEFAULT NULL::character varying,
    cropped_fpfile_photo character varying(8000) DEFAULT NULL::character varying,
    cropped_s3_path_photo character varying(512) DEFAULT NULL::character varying,
    crop_selection_photo character varying(256) DEFAULT NULL::character varying,
    lat numeric(15,10),
    lng numeric(15,10),
    large_photo_url character varying(2048),
    cropped_large_s3_path_photo character varying(512),
    cropped_large_fpfile_photo character varying(8000),
    did_real_session boolean DEFAULT false,
    band_type character varying(16) DEFAULT ''::character varying,
    band_status character varying(16) DEFAULT ''::character varying,
    concert_count smallint DEFAULT 0,
    add_new_members boolean DEFAULT false,
    play_commitment smallint DEFAULT 0,
    touring_option boolean DEFAULT false,
    paid_gigs boolean DEFAULT false,
    free_gigs boolean DEFAULT false,
    hourly_rate integer,
    gig_minimum integer,
    school_id integer
);


--
-- Name: bands_musicians; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.bands_musicians (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    band_id character varying(64) NOT NULL,
    user_id character varying(64) NOT NULL,
    admin boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: broadcast_notification_views; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.broadcast_notification_views (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    broadcast_notification_id character varying(64) NOT NULL,
    view_count integer DEFAULT 0,
    active_at timestamp without time zone DEFAULT now() NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: broadcast_notifications; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.broadcast_notifications (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    title character varying(64),
    message character varying(256),
    button_label character varying(32),
    button_url character varying,
    frequency integer DEFAULT 0,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: broadcasts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.broadcasts (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    music_session_id character varying(64) NOT NULL,
    user_id character varying(64) NOT NULL,
    broadcast_id character varying NOT NULL,
    stream_id character varying,
    broadcast_status character varying,
    stream_status character varying,
    stream_name character varying,
    stream_address character varying,
    broadcast_data character varying,
    stream_data character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: calendars; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.calendars (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    target_uid character varying(64) NOT NULL,
    name character varying(128),
    description character varying(8000),
    trigger_delete boolean DEFAULT false,
    start_at timestamp without time zone NOT NULL,
    end_at timestamp without time zone NOT NULL,
    recurring_mode character varying(50) DEFAULT 'once'::character varying NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: campaign_spends; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.campaign_spends (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    campaign character varying NOT NULL,
    spend numeric(8,2) NOT NULL,
    month integer NOT NULL,
    year integer NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: charges; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.charges (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    amount_in_cents integer NOT NULL,
    fee_in_cents integer DEFAULT 0 NOT NULL,
    type character varying(64) NOT NULL,
    sent_billing_notices boolean DEFAULT false NOT NULL,
    sent_billing_notices_at timestamp without time zone,
    last_billing_attempt_at timestamp without time zone,
    billed boolean DEFAULT false NOT NULL,
    billed_at timestamp without time zone,
    post_processed boolean DEFAULT false NOT NULL,
    post_processed_at timestamp without time zone,
    billing_error_reason character varying,
    billing_error_detail character varying,
    billing_should_retry boolean DEFAULT true NOT NULL,
    billing_attempts integer DEFAULT 0 NOT NULL,
    stripe_charge_id character varying(200),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    user_id character varying(64)
);


--
-- Name: chat_messages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.chat_messages (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    music_session_id character varying(64),
    message text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    channel character varying(128) DEFAULT 'session'::character varying NOT NULL,
    target_user_id character varying(64),
    lesson_session_id character varying(64),
    purpose character varying(200),
    music_notation_id character varying(64),
    claimed_recording_id character varying(64)
);


--
-- Name: cities; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cities (
    city character varying(255) NOT NULL,
    region character varying(2) NOT NULL,
    countrycode character varying(2) NOT NULL
);


--
-- Name: claimed_recordings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.claimed_recordings (
    user_id character varying(64) NOT NULL,
    recording_id character varying(64) NOT NULL,
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying(200) NOT NULL,
    is_public boolean DEFAULT true NOT NULL,
    genre_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    description character varying(8000),
    description_tsv tsvector,
    name_tsv tsvector,
    discarded boolean DEFAULT false,
    upload_to_youtube boolean DEFAULT false NOT NULL
);


--
-- Name: client_live_streams; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.client_live_streams (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    music_session_id character varying(64),
    message character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: cohorts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.cohorts (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    data_set json DEFAULT '{}'::json NOT NULL,
    group_start timestamp without time zone NOT NULL,
    group_end timestamp without time zone NOT NULL,
    all_time boolean DEFAULT false NOT NULL,
    monthly_start timestamp without time zone,
    monthly_end timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: connections_client_id_int_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.connections_client_id_int_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: connections; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.connections (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    client_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    music_session_id character varying(64),
    ip_address character varying(64) NOT NULL,
    as_musician boolean,
    aasm_state character varying(64) DEFAULT 'idle'::character varying NOT NULL,
    addr bigint NOT NULL,
    locidispid bigint,
    joined_session_at timestamp without time zone,
    client_type character varying(256) NOT NULL,
    stale_time integer DEFAULT 40 NOT NULL,
    expire_time integer DEFAULT 60 NOT NULL,
    last_jam_audio_latency double precision,
    channel_id character varying(256) NOT NULL,
    udp_reachable boolean DEFAULT true NOT NULL,
    scoring_timeout timestamp without time zone DEFAULT now() NOT NULL,
    scoring_failures integer DEFAULT 0 NOT NULL,
    scoring_timeout_occurrences integer DEFAULT 0 NOT NULL,
    scoring_failures_offset integer DEFAULT 0 NOT NULL,
    gateway character varying DEFAULT 'default-1'::character varying NOT NULL,
    is_network_testing boolean DEFAULT false NOT NULL,
    metronome_open boolean DEFAULT false NOT NULL,
    user_active boolean DEFAULT true,
    is_jamblaster boolean DEFAULT false,
    client_role character varying,
    parent_client_id character varying,
    client_id_int integer DEFAULT nextval('public.connections_client_id_int_seq'::regclass) NOT NULL
);


--
-- Name: countries; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.countries (
    countrycode character varying(2) NOT NULL,
    countryname character varying(64)
);


--
-- Name: crash_dumps; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.crash_dumps (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    client_type character varying(64) NOT NULL,
    client_id character varying(64),
    user_id character varying(64),
    session_id character varying(64),
    "timestamp" timestamp without time zone,
    uri character varying(1000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    client_version character varying(100) NOT NULL,
    description character varying(20000),
    crash_context character varying(10000),
    fsize character varying(10000)
);


--
-- Name: current_network_scores; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.current_network_scores (
    alocidispid bigint NOT NULL,
    blocidispid bigint NOT NULL,
    score integer NOT NULL,
    limited boolean NOT NULL,
    score_dt timestamp without time zone NOT NULL
);


--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.users (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    email character varying(255) NOT NULL,
    remember_token character varying(255),
    encrypted_password character varying(255) NOT NULL,
    admin boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    musician boolean DEFAULT false NOT NULL,
    city character varying(100),
    state character varying(100),
    country character varying(100),
    first_name character varying(50),
    last_name character varying(50),
    birth_date date,
    gender character(1),
    signup_token character varying(255),
    email_confirmed boolean DEFAULT false,
    photo_url character varying(2048),
    session_settings character varying(4000),
    reset_password_token character varying(64),
    reset_password_token_created timestamp without time zone,
    can_invite boolean DEFAULT true NOT NULL,
    name_tsv tsvector,
    environment character varying(255) DEFAULT 'public'::character varying NOT NULL,
    subscribe_email boolean DEFAULT true,
    update_email character varying(1024),
    update_email_token character varying(1024),
    original_fpfile character varying(8000) DEFAULT NULL::character varying,
    cropped_fpfile character varying(8000) DEFAULT NULL::character varying,
    cropped_s3_path character varying(512) DEFAULT NULL::character varying,
    crop_selection character varying(256) DEFAULT NULL::character varying,
    last_failed_certified_gear_at timestamp without time zone,
    last_failed_certified_gear_reason character varying(256),
    first_downloaded_client_at timestamp without time zone,
    first_ran_client_at timestamp without time zone,
    first_certified_gear_at timestamp without time zone,
    first_music_session_at timestamp without time zone,
    first_real_music_session_at timestamp without time zone,
    first_good_music_session_at timestamp without time zone,
    first_invited_at timestamp without time zone,
    first_friended_at timestamp without time zone,
    first_social_promoted_at timestamp without time zone,
    show_whats_next boolean DEFAULT true,
    biography text,
    icecast_server_group_id character varying(64) DEFAULT 'default'::character varying NOT NULL,
    first_recording_at timestamp without time zone,
    large_photo_url character varying(2048),
    cropped_large_s3_path character varying(512),
    cropped_large_fpfile character varying(8000),
    notification_seen_at timestamp without time zone,
    mods json,
    last_jam_audio_latency double precision,
    last_jam_addr bigint,
    last_jam_locidispid bigint,
    last_jam_updated_reason character(1),
    last_jam_updated_at timestamp without time zone,
    statecode character varying(2),
    countrycode character varying(2),
    recurly_code character varying(50) DEFAULT NULL::character varying,
    online boolean DEFAULT false NOT NULL,
    website character varying(4000),
    skill_level smallint,
    concert_count smallint,
    studio_session_count smallint,
    virtual_band boolean DEFAULT false NOT NULL,
    virtual_band_commitment smallint,
    traditional_band boolean DEFAULT false NOT NULL,
    traditional_band_commitment smallint,
    traditional_band_touring boolean,
    paid_sessions boolean DEFAULT false NOT NULL,
    paid_sessions_hourly_rate integer,
    paid_sessions_daily_rate integer,
    free_sessions boolean DEFAULT false NOT NULL,
    cowriting boolean DEFAULT false NOT NULL,
    cowriting_purpose smallint,
    reuse_card boolean DEFAULT true NOT NULL,
    has_redeemable_jamtrack boolean DEFAULT true NOT NULL,
    show_whats_next_count integer DEFAULT 0 NOT NULL,
    want_jamblaster boolean DEFAULT false NOT NULL,
    first_played_jamtrack_at timestamp without time zone,
    affiliate_referral_id integer,
    first_opened_jamtrack_web_player timestamp without time zone,
    gifted_jamtracks integer DEFAULT 0,
    email_needs_verification boolean DEFAULT false,
    kickbox_response json,
    bounced boolean DEFAULT false,
    teacher_id character varying(64),
    is_a_student boolean DEFAULT false NOT NULL,
    is_a_teacher boolean DEFAULT false NOT NULL,
    ready_for_session_at timestamp without time zone,
    remaining_free_lessons integer DEFAULT 1 NOT NULL,
    stored_credit_card boolean DEFAULT false NOT NULL,
    remaining_test_drives integer DEFAULT 0 NOT NULL,
    stripe_token character varying(200),
    stripe_customer_id character varying(200),
    stripe_zip_code character varying(200),
    school_id integer,
    joined_school_at timestamp without time zone,
    school_interest boolean DEFAULT false,
    lesson_package_type_id character varying(64),
    phantom boolean DEFAULT false NOT NULL,
    origin_utm_source character varying DEFAULT 'legacy'::character varying,
    origin_utm_medium character varying,
    origin_utm_campaign character varying,
    origin_referrer character varying,
    jamclass_credits integer DEFAULT 0,
    education_interest boolean DEFAULT false NOT NULL,
    retailer_interest boolean DEFAULT false NOT NULL,
    lesson_package_needs_purchase_id character varying(64),
    under_13 boolean,
    via_amazon boolean,
    is_onboarder boolean DEFAULT false NOT NULL,
    onboarding_status character varying DEFAULT 'Unassigned'::character varying,
    onboarding_lost_reason character varying,
    onboarding_lost_at date,
    onboarding_escalation_reason character varying,
    onboarding_escalated_at date,
    onboarder_id character varying(64),
    onboarder_assigned_at date,
    onboarding_email_1_sent_at date,
    onboarding_email_2_sent_at date,
    onboarding_email_3_sent_at date,
    onboarding_email_4_sent_at date,
    onboarding_email_5_sent_at date,
    onboarding_test_session_scheduled_at date,
    onboarding_test_session_at timestamp without time zone,
    onboarding_test_session_outcome character varying,
    onboarding_onboarded_at date,
    onboarding_onboarder_notes character varying,
    first_onboarding_free_lesson_at timestamp without time zone,
    first_onboarding_paid_lesson_at timestamp without time zone,
    timezone character varying,
    deleted boolean DEFAULT false NOT NULL,
    max_onboardings integer DEFAULT 0 NOT NULL,
    sent_take_flesson_email_at timestamp without time zone,
    sent_take_flesson_email_times integer DEFAULT 0 NOT NULL,
    sent_take_2nd_flesson_email_at timestamp without time zone,
    sent_take_2nd_flesson_email_times integer DEFAULT 0 NOT NULL,
    sent_take_plesson_email_at timestamp without time zone,
    sent_take_plesson_email_times integer DEFAULT 0 NOT NULL,
    second_onboarding_free_lesson_at timestamp without time zone,
    sent_admin_take_flesson_email_at timestamp without time zone,
    sent_admin_take_2nd_flesson_email_at timestamp without time zone,
    sent_admin_take_plesson_email_at timestamp without time zone,
    stuck_take_flesson boolean DEFAULT false NOT NULL,
    stuck_take_2nd_flesson boolean DEFAULT false NOT NULL,
    stuck_take_plesson boolean DEFAULT false NOT NULL,
    send_onboarding_survey boolean DEFAULT false NOT NULL,
    sent_onboarding_survey_at timestamp without time zone,
    first_lesson_booked_at timestamp without time zone,
    remind_take_lesson_times integer DEFAULT 0 NOT NULL,
    remind_take_lesson_at timestamp without time zone,
    sent_first_lesson_instr_email_at timestamp without time zone,
    beta boolean DEFAULT false,
    is_platform_instructor boolean DEFAULT false NOT NULL,
    import_source character varying(50),
    license_start date,
    license_end date,
    recurly_subscription_id character varying(100) DEFAULT NULL::character varying,
    recurly_token character varying(200) DEFAULT NULL::character varying,
    recurly_subscription_state character varying(20) DEFAULT NULL::character varying,
    subscription_plan_code character varying(100) DEFAULT NULL::character varying,
    desired_plan_code character varying(100) DEFAULT NULL::character varying,
    admin_override_plan_code character varying(100) DEFAULT NULL::character varying,
    admin_override_ends_at date,
    admin_override_reason character varying,
    desired_plan_code_set_at timestamp without time zone,
    subscription_plan_code_set_at timestamp without time zone,
    subscription_last_checked_at timestamp without time zone,
    subscription_sync_code character varying,
    subscription_sync_msg character varying,
    client_fingerprint character varying(255),
    is_past_due boolean DEFAULT false,
    subscription_trial_ends_at timestamp without time zone DEFAULT now() NOT NULL,
    subscription_plan_reason character varying(20),
    used_current_month integer,
    used_month_play_time integer
);


--
-- Name: current_scores; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.current_scores AS
 SELECT current_network_scores.alocidispid,
    current_network_scores.blocidispid,
    current_network_scores.score,
    current_network_scores.limited,
    current_network_scores.score_dt,
    a_users.id AS a_userid,
    b_users.id AS b_userid,
    ((COALESCE(a_users.last_jam_audio_latency, (13)::double precision) + COALESCE(b_users.last_jam_audio_latency, (13)::double precision)) + (current_network_scores.score)::double precision) AS full_score,
    a_users.last_jam_audio_latency AS a_audio_latency,
    b_users.last_jam_audio_latency AS b_audio_latency
   FROM ((public.current_network_scores
     JOIN public.users a_users ON ((a_users.last_jam_locidispid = current_network_scores.alocidispid)))
     JOIN public.users b_users ON ((b_users.last_jam_locidispid = current_network_scores.blocidispid)))
  ORDER BY ((COALESCE(a_users.last_jam_audio_latency, (13)::double precision) + COALESCE(b_users.last_jam_audio_latency, (13)::double precision)) + (current_network_scores.score)::double precision);


--
-- Name: diagnostics; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.diagnostics (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    type character varying(255) NOT NULL,
    creator character varying(255) NOT NULL,
    data text,
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: download_trackers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.download_trackers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    remote_ip character varying(400) NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    paid boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    fingerprint character varying(1000),
    is_client boolean DEFAULT false
);


--
-- Name: email_batch_sets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.email_batch_sets (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    email_batch_id character varying(64),
    started_at timestamp without time zone,
    user_ids text DEFAULT ''::text NOT NULL,
    batch_count integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    trigger_index integer DEFAULT 0 NOT NULL,
    sub_type character varying(64),
    user_id character varying(64)
);


--
-- Name: email_batches; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.email_batches (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    subject character varying(256),
    body text,
    from_email character varying(64) DEFAULT 'JamKazam <noreply@jamkazam.com>'::character varying NOT NULL,
    aasm_state character varying(32) DEFAULT 'pending'::character varying NOT NULL,
    test_emails text DEFAULT 'test@jamkazam.com'::text NOT NULL,
    opt_in_count integer DEFAULT 0 NOT NULL,
    sent_count integer DEFAULT 0 NOT NULL,
    lock_version integer,
    started_at timestamp without time zone,
    completed_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    type character varying(64) DEFAULT 'JamRuby::EmailBatch'::character varying NOT NULL,
    sub_type character varying(64)
);


--
-- Name: email_blacklists; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.email_blacklists (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    email character varying(1000) NOT NULL,
    source character varying(1000),
    notes character varying(1000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: email_errors; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.email_errors (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    error_type character varying(32),
    email_address character varying(256),
    status character varying(32),
    email_date timestamp without time zone DEFAULT now(),
    reason text,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: event_brite_order_uploads; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event_brite_order_uploads (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    upload_file_name character varying(500) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: event_brite_orders; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event_brite_orders (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    live_stream_id character varying(64),
    event_brite_order_upload_id character varying(64),
    event_name character varying(100) NOT NULL,
    order_id character varying(100) NOT NULL,
    ticket_count integer,
    ticket_type character varying(100),
    first_name character varying(100),
    last_name character varying(100),
    email character varying(200),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    times_claimed integer DEFAULT 0 NOT NULL
);


--
-- Name: event_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.event_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    starts_at timestamp without time zone,
    ends_at timestamp without time zone,
    pinned_state character varying(255),
    img_url character varying(1024),
    img_width integer,
    img_height integer,
    event_id character varying(64),
    user_id character varying(64),
    band_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ordinal integer
);


--
-- Name: events; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.events (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    slug character varying(512) NOT NULL,
    title text,
    description text,
    show_sponser boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    social_description text
);


--
-- Name: facebook_signups; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.facebook_signups (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    lookup_id character varying(255) NOT NULL,
    last_name character varying(100),
    first_name character varying(100),
    gender character varying(1),
    email character varying(1024),
    uid character varying(1024),
    token character varying(1024),
    token_expires_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: fan_invitations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.fan_invitations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    sender_id character varying(64),
    receiver_id character varying(64),
    music_session_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: feeds; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.feeds (
    id bigint NOT NULL,
    recording_id character varying(64),
    music_session_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    active boolean DEFAULT false,
    school_id integer,
    is_platform_instructor boolean DEFAULT false NOT NULL
);


--
-- Name: feeds_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.feeds_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: feeds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.feeds_id_seq OWNED BY public.feeds.id;


--
-- Name: fingerprint_whitelists; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.fingerprint_whitelists (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    fingerprint character varying(20000) NOT NULL
);


--
-- Name: follows; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.follows (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    followable_id character varying(64) NOT NULL,
    followable_type character varying(25) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: fraud_alerts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.fraud_alerts (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    machine_fingerprint_id character varying(64) NOT NULL,
    user_id character varying(64) NOT NULL,
    resolved boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: friend_requests; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.friend_requests (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    friend_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    status character varying(50),
    message character varying(4000)
);


--
-- Name: friendships; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.friendships (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    friend_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: generic_state; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.generic_state (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    score_history_last_imported_at timestamp without time zone,
    env character varying(255) DEFAULT 'development'::character varying NOT NULL,
    affiliate_tallied_at timestamp without time zone,
    bounce_check_at date,
    top_message character varying(100000),
    event_page_top_logo_url character varying(100000) DEFAULT '/assets/event/eventbrite-logo.png'::character varying,
    connection_policy character varying
);


--
-- Name: genre_players; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.genre_players (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    player_id character varying(64) NOT NULL,
    genre_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    player_type character varying(128),
    genre_type character varying(20) DEFAULT 'profile'::character varying
);


--
-- Name: genres; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.genres (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    description character varying(1024) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: genres_jam_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.genres_jam_tracks (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    genre_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: genres_music_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.genres_music_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    genre_id character varying(64),
    music_session_id character varying(64)
);


--
-- Name: geoipblocks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.geoipblocks (
    beginip bigint NOT NULL,
    endip bigint NOT NULL,
    locid integer NOT NULL
);


--
-- Name: geoipisp; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.geoipisp (
    beginip bigint NOT NULL,
    endip bigint NOT NULL,
    company character varying(50) NOT NULL
);


--
-- Name: geoiplocations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.geoiplocations (
    locid integer NOT NULL,
    countrycode character varying(2),
    region character varying(2),
    city character varying(255),
    postalcode character varying(8),
    latitude double precision NOT NULL,
    longitude double precision NOT NULL,
    metrocode integer,
    areacode character(3)
);


--
-- Name: gift_card_purchases; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.gift_card_purchases (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    gift_card_type_id character varying(64),
    recurly_adjustment_uuid character varying(500),
    recurly_adjustment_credit_uuid character varying(500),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: gift_card_types; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.gift_card_types (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    card_type character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: gift_cards; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.gift_cards (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    code character varying(64) NOT NULL,
    user_id character varying(64),
    card_type character varying(64) NOT NULL,
    origin character varying(200),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_admin_authentications; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_admin_authentications (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    source_pass character varying(64) NOT NULL,
    relay_user character varying(64) NOT NULL,
    relay_pass character varying(64) NOT NULL,
    admin_user character varying(64) NOT NULL,
    admin_pass character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_directories; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_directories (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    yp_url_timeout integer DEFAULT 15 NOT NULL,
    yp_url character varying(1024) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_limits; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_limits (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    clients integer DEFAULT 1000 NOT NULL,
    sources integer DEFAULT 50 NOT NULL,
    queue_size integer DEFAULT 102400 NOT NULL,
    client_timeout integer DEFAULT 30,
    header_timeout integer DEFAULT 15,
    source_timeout integer DEFAULT 10,
    burst_size integer DEFAULT 65536,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_listen_sockets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_listen_sockets (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    port integer DEFAULT 8001 NOT NULL,
    bind_address character varying(1024),
    shoutcast_mount character varying(1024),
    shoutcast_compat integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_loggings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_loggings (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    access_log character varying(1024) DEFAULT 'access.log'::character varying NOT NULL,
    error_log character varying(1024) DEFAULT 'error.log'::character varying NOT NULL,
    playlist_log character varying(1024),
    log_level integer DEFAULT 3 NOT NULL,
    log_archive integer,
    log_size integer DEFAULT 10000,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_master_server_relays; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_master_server_relays (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    master_server character varying(1024) NOT NULL,
    master_server_port integer DEFAULT 8001 NOT NULL,
    master_update_interval integer DEFAULT 120 NOT NULL,
    master_username character varying(64) NOT NULL,
    master_pass character varying(64) NOT NULL,
    relays_on_demand integer DEFAULT 1 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_mount_templates; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_mount_templates (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying(256) NOT NULL,
    source_username character varying(64),
    source_pass character varying(64),
    max_listeners integer DEFAULT 4,
    max_listener_duration integer DEFAULT 3600,
    dump_file character varying(1024),
    intro character varying(1024),
    fallback_mount character varying(1024),
    fallback_override integer DEFAULT 1,
    fallback_when_full integer DEFAULT 1,
    charset character varying(1024) DEFAULT 'ISO8859-1'::character varying,
    is_public integer DEFAULT 0,
    stream_name character varying(1024),
    stream_description character varying(10000),
    stream_url character varying(1024),
    genre character varying(256),
    bitrate integer,
    mime_type character varying(64) DEFAULT 'audio/mpeg'::character varying NOT NULL,
    subtype character varying(64),
    burst_size integer,
    mp3_metadata_interval integer,
    hidden integer DEFAULT 1,
    on_connect character varying(1024),
    on_disconnect character varying(1024),
    authentication_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_mounts; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.icecast_mounts (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying(1024) NOT NULL,
    source_username character varying(64),
    source_pass character varying(64),
    max_listeners integer DEFAULT 4,
    max_listener_duration integer DEFAULT 3600,
    dump_file character varying(1024),
    intro character varying(1024),
    fallback_mount character varying(1024),
    fallback_override integer DEFAULT 1,
    fallback_when_full integer DEFAULT 1,
    charset character varying(1024) DEFAULT 'ISO8859-1'::character varying,
    is_public integer DEFAULT 0,
    stream_name character varying(1024),
    stream_description character varying(10000),
    stream_url character varying(1024),
    genre character varying(256),
    bitrate integer,
    mime_type character varying(64),
    subtype character varying(64),
    burst_size integer,
    mp3_metadata_interval integer,
    hidden integer DEFAULT 1,
    on_connect character varying(1024),
    on_disconnect character varying(1024),
    authentication_id character varying(64) DEFAULT NULL::character varying,
    listeners integer DEFAULT 0 NOT NULL,
    sourced boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    music_session_id character varying(64),
    icecast_server_id character varying(64) NOT NULL,
    icecast_mount_template_id character varying(64),
    sourced_needs_changing_at timestamp without time zone,
    source_direction boolean DEFAULT false NOT NULL
);


--
-- Name: icecast_paths; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_paths (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    base_dir character varying(1024) DEFAULT './'::character varying NOT NULL,
    log_dir character varying(1024) DEFAULT './logs'::character varying NOT NULL,
    pid_file character varying(1024) DEFAULT './icecast.pid'::character varying,
    web_root character varying(1024) DEFAULT './web'::character varying NOT NULL,
    admin_root character varying(1024) DEFAULT './admin'::character varying NOT NULL,
    allow_ip character varying(1024),
    deny_ip character varying(1024),
    alias_source character varying(1024),
    alias_dest character varying(1024),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_relays; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_relays (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    server character varying(1024) NOT NULL,
    port integer DEFAULT 8001 NOT NULL,
    mount character varying(1024) NOT NULL,
    local_mount character varying(1024),
    relay_username character varying(64),
    relay_pass character varying(64),
    relay_shoutcast_metadata integer DEFAULT 0,
    on_demand integer DEFAULT 1,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_securities; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_securities (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    chroot integer DEFAULT 0 NOT NULL,
    change_owner_user character varying(64),
    change_owner_group character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_server_groups; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_server_groups (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying(255) NOT NULL
);


--
-- Name: icecast_server_mounts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_server_mounts (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    icecast_mount_id character varying(64),
    icecast_server_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_server_relays; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_server_relays (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    icecast_relay_id character varying(64),
    icecast_server_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_server_sockets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_server_sockets (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    icecast_listen_socket_id character varying(64),
    icecast_server_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_servers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_servers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    config_changed integer DEFAULT 0,
    limit_id character varying(64),
    admin_auth_id character varying(64),
    directory_id character varying(64),
    master_relay_id character varying(64),
    path_id character varying(64),
    logging_id character varying(64),
    security_id character varying(64),
    template_id character varying(64) NOT NULL,
    hostname character varying(1024) NOT NULL,
    server_id character varying(1024) NOT NULL,
    location character varying(1024),
    admin_email character varying(1024),
    fileserve integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    icecast_server_group_id character varying(64) DEFAULT 'default'::character varying NOT NULL,
    mount_template_id character varying(64),
    config_updated_at timestamp without time zone
);


--
-- Name: icecast_source_changes; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.icecast_source_changes (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    source_direction boolean NOT NULL,
    change_type character varying(64) NOT NULL,
    user_id character varying(64),
    client_id character varying(64),
    success boolean NOT NULL,
    reason character varying,
    detail character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    icecast_mount_id character varying(64) NOT NULL
);


--
-- Name: icecast_template_sockets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_template_sockets (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    icecast_listen_socket_id character varying(64),
    icecast_template_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_templates; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.icecast_templates (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    limit_id character varying(64),
    admin_auth_id character varying(64),
    directory_id character varying(64),
    master_relay_id character varying(64),
    path_id character varying(64),
    logging_id character varying(64),
    security_id character varying(64),
    location character varying(1024) NOT NULL,
    name character varying(256) NOT NULL,
    admin_email character varying(1024) DEFAULT 'admin@jamkazam.com'::character varying NOT NULL,
    fileserve integer DEFAULT 1 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: icecast_user_authentications; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.icecast_user_authentications (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    authentication_type character varying(16) DEFAULT 'url'::character varying,
    filename character varying(1024),
    allow_duplicate_users integer,
    mount_add character varying(1024),
    mount_remove character varying(1024),
    listener_add character varying(1024),
    listener_remove character varying(1024),
    unused_username character varying(64),
    unused_pass character varying(64),
    auth_header character varying(64) DEFAULT 'icecast-auth-user: 1'::character varying,
    timelimit_header character varying(64) DEFAULT 'icecast-auth-timelimit:'::character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: instruments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.instruments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    description character varying(1024) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    popularity integer DEFAULT 0 NOT NULL
);


--
-- Name: invitations; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.invitations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    sender_id character varying(64),
    receiver_id character varying(64),
    music_session_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    join_request_id character varying(64)
);


--
-- Name: invited_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.invited_users (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    sender_id character varying(64),
    autofriend boolean NOT NULL,
    email character varying(256),
    invitation_code character varying(256) NOT NULL,
    accepted boolean DEFAULT false,
    note text,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    invite_medium character varying(64),
    receiver_id character varying(64)
);


--
-- Name: ip_blacklists; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ip_blacklists (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    remote_ip character varying(400) NOT NULL,
    notes character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: ip_whitelists; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ip_whitelists (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    remote_ip character varying(400) NOT NULL,
    notes character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: isp_score_batch; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.isp_score_batch (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    json_scoring_data text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: jam_class_reports; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_class_reports (
    cohort date,
    campaign character varying,
    spend numeric(8,2),
    registrations integer,
    td_customers integer,
    jamclass_rev numeric(8,2),
    td4 integer,
    td2 integer,
    td1 integer,
    spend_td numeric(8,2),
    purchases0 numeric(8,2),
    purchases1 numeric(8,2),
    purchases2 numeric(8,2),
    purchases3 numeric(8,2),
    purchases_rest numeric(8,2),
    purchases0_count integer,
    purchases1_count integer,
    purchases2_count integer,
    purchases3_count integer,
    purchases_rest_count integer,
    purchases_count integer
);


--
-- Name: jam_track_files; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_files (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    jam_track_id character varying(64),
    file_type character varying NOT NULL,
    original_filename character varying NOT NULL,
    precount_num integer,
    url character varying,
    md5 character varying,
    length bigint,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: jam_track_hfa_request_ids; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_hfa_request_ids (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    jam_track_hfa_request_id integer,
    request_id integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: jam_track_hfa_requests; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_hfa_requests (
    id integer NOT NULL,
    name character varying NOT NULL,
    request_csv_filename character varying,
    response_csv_filename character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    approved_at timestamp without time zone,
    received_at timestamp without time zone
);


--
-- Name: jam_track_hfa_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.jam_track_hfa_requests_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: jam_track_hfa_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.jam_track_hfa_requests_id_seq OWNED BY public.jam_track_hfa_requests.id;


--
-- Name: jam_track_licensors; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_licensors (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying NOT NULL,
    description text,
    attention text,
    address_line_1 character varying,
    address_line_2 character varying,
    city character varying,
    state character varying,
    zip_code character varying,
    contact character varying,
    email character varying,
    phone character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    slug character varying
);


--
-- Name: jam_track_mixdown_packages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_mixdown_packages (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    jam_track_mixdown_id character varying(64) NOT NULL,
    file_type character varying NOT NULL,
    sample_rate integer NOT NULL,
    url character varying(2048),
    md5 character varying,
    length integer,
    downloaded_since_sign boolean DEFAULT false NOT NULL,
    last_step_at timestamp without time zone,
    last_signed_at timestamp without time zone,
    download_count integer DEFAULT 0 NOT NULL,
    signed_at timestamp without time zone,
    downloaded_at timestamp without time zone,
    signing_queued_at timestamp without time zone,
    error_count integer DEFAULT 0 NOT NULL,
    error_reason character varying,
    error_detail character varying,
    should_retry boolean DEFAULT false NOT NULL,
    packaging_steps integer,
    current_packaging_step integer,
    private_key character varying,
    signed boolean,
    signing_started_at timestamp without time zone,
    first_downloaded timestamp without time zone,
    signing boolean DEFAULT false NOT NULL,
    encrypt_type character varying,
    first_downloaded_at timestamp without time zone,
    last_downloaded_at timestamp without time zone,
    version character varying DEFAULT '1'::character varying NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    last_errored_at timestamp without time zone,
    queued boolean DEFAULT false,
    speed_pitched boolean DEFAULT false
);


--
-- Name: jam_track_mixdowns; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_mixdowns (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    user_id character varying(64) NOT NULL,
    settings json NOT NULL,
    name character varying(1000) NOT NULL,
    description character varying(1000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: tracks_next_tracker_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.tracks_next_tracker_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: jam_track_rights; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_rights (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    user_id character varying(64) NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    url_48 character varying(2048),
    md5_48 character varying,
    length_48 integer DEFAULT 0 NOT NULL,
    download_count integer DEFAULT 0 NOT NULL,
    downloaded_since_sign boolean DEFAULT false NOT NULL,
    last_signed_at timestamp without time zone,
    last_downloaded_at timestamp without time zone,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    signing_queued_at timestamp without time zone,
    error_count integer DEFAULT 0 NOT NULL,
    error_reason character varying,
    error_detail character varying,
    should_retry boolean DEFAULT false NOT NULL,
    url_44 character varying,
    md5_44 character varying,
    length_44 bigint,
    redeemed boolean DEFAULT false NOT NULL,
    is_test_purchase boolean DEFAULT false NOT NULL,
    recurly_adjustment_uuid character varying(500),
    recurly_adjustment_credit_uuid character varying(500),
    packaging_steps integer,
    current_packaging_step integer,
    last_step_at timestamp without time zone,
    private_key_44 character varying,
    private_key_48 character varying,
    signed_48 boolean DEFAULT false NOT NULL,
    signed_44 boolean DEFAULT false NOT NULL,
    signing_started_at_44 timestamp without time zone,
    signing_started_at_48 timestamp without time zone,
    first_downloaded_at timestamp without time zone,
    signing_44 boolean DEFAULT false,
    signing_48 boolean DEFAULT false,
    redeemed_and_fingerprinted boolean DEFAULT false,
    last_mixdown_id character varying(64),
    queued boolean DEFAULT false,
    last_stem_id character varying(64),
    version character varying DEFAULT '0'::character varying NOT NULL,
    posa_card_id character varying(64),
    can_download boolean DEFAULT false NOT NULL
);


--
-- Name: jam_track_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    session_type character varying(10) NOT NULL,
    music_session_id character varying(64),
    user_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: jam_track_tap_ins; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_tap_ins (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    offset_time integer NOT NULL,
    jam_track_id character varying(64) NOT NULL,
    bpm numeric NOT NULL,
    tap_in_count integer DEFAULT 0 NOT NULL
);


--
-- Name: jam_track_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_track_tracks (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    "position" integer,
    track_type character varying,
    jam_track_id character varying(64) NOT NULL,
    instrument_id character varying(64),
    part character varying,
    url_48 character varying,
    md5_48 character varying,
    length_48 bigint,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    url_44 character varying,
    md5_44 character varying,
    length_44 bigint,
    preview_url character varying,
    preview_md5 character varying,
    preview_length bigint,
    preview_start_time integer,
    preview_mp3_url character varying,
    preview_mp3_md5 character varying,
    preview_mp3_length bigint,
    original_filename character varying,
    preview_aac_url character varying,
    preview_aac_md5 character varying,
    preview_aac_length bigint,
    url_mp3_48 character varying,
    md5_mp3_48 character varying,
    length_mp3_48 bigint,
    url_aac_48 character varying,
    md5_aac_48 character varying,
    length_aac_48 bigint
);


--
-- Name: jam_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jam_tracks (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying NOT NULL,
    description text,
    time_signature character varying,
    status character varying,
    recording_type character varying,
    original_artist text,
    songwriter text,
    publisher text,
    sales_region character varying,
    price numeric,
    reproduction_royalty boolean,
    public_performance_royalty boolean,
    reproduction_royalty_amount numeric,
    licensor_royalty_amount numeric,
    licensor_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    plan_code character varying(50) DEFAULT NULL::character varying,
    version character varying DEFAULT 0 NOT NULL,
    jmep_text character varying,
    jmep_json json,
    metalocation character varying,
    pro_ascap boolean DEFAULT false NOT NULL,
    pro_bmi boolean DEFAULT false NOT NULL,
    pro_sesac boolean DEFAULT false NOT NULL,
    duration integer,
    onboarding_exceptions json,
    additional_info character varying,
    language character varying DEFAULT 'eng'::character varying NOT NULL,
    year integer,
    vendor_id character varying,
    search_tsv tsvector,
    artist_tsv tsvector,
    name_tsv tsvector,
    server_fixation_date date DEFAULT now(),
    hfa_license_status boolean DEFAULT false,
    hfa_license_desired boolean DEFAULT true,
    alternative_license_status boolean DEFAULT false,
    hfa_license_number integer,
    hfa_song_code character varying,
    album_title character varying,
    slug character varying(2000),
    bpm numeric(8,3),
    allow_free boolean DEFAULT true,
    download_price numeric
);


--
-- Name: jam_tracks_next_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.jam_tracks_next_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: jamblaster_pairing_requests; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jamblaster_pairing_requests (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    jamblaster_id character varying(64) NOT NULL,
    jamblaster_client_id character varying(64) NOT NULL,
    sibling_key character varying(1000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    vtoken character varying(400) NOT NULL,
    active boolean DEFAULT false NOT NULL
);


--
-- Name: jamblasters; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jamblasters (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    serial_no character varying(1000),
    client_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ipv6_link_local character varying,
    ipv4_link_local character varying,
    display_name character varying
);


--
-- Name: jamblasters_users; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jamblasters_users (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    jamblaster_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: jamcompany; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jamcompany (
    coid integer NOT NULL,
    company character varying(50) NOT NULL
);


--
-- Name: jamcompany_coid_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.jamcompany_coid_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: jamcompany_coid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.jamcompany_coid_seq OWNED BY public.jamcompany.coid;


--
-- Name: jamisp; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.jamisp (
    beginip bigint NOT NULL,
    endip bigint NOT NULL,
    coid integer NOT NULL
);


--
-- Name: join_requests; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.join_requests (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    music_session_id character varying(64),
    text character varying(2000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: json_stores; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.json_stores (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    foreign_key1_id character varying(64),
    data_blob json DEFAULT '{}'::json NOT NULL,
    type character varying(128)
);


--
-- Name: languages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.languages (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    description character varying(1024)
);


--
-- Name: latency_testers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.latency_testers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    client_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: lesson_booking_slots; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.lesson_booking_slots (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    lesson_booking_id character varying(64),
    lesson_session_id character varying(64),
    slot_type character varying(64) NOT NULL,
    preferred_day date,
    day_of_week integer,
    hour integer,
    minute integer,
    timezone character varying NOT NULL,
    message character varying,
    accept_message character varying,
    update_all boolean DEFAULT false NOT NULL,
    proposer_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    from_package boolean DEFAULT false
);


--
-- Name: lesson_bookings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.lesson_bookings (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    active boolean DEFAULT false NOT NULL,
    accepter_id character varying(64),
    canceler_id character varying(64),
    lesson_type character varying(64) NOT NULL,
    recurring boolean NOT NULL,
    lesson_length integer NOT NULL,
    payment_style character varying(64) NOT NULL,
    description character varying,
    booked_price numeric(8,2) NOT NULL,
    teacher_id character varying(64) NOT NULL,
    card_presumed_ok boolean DEFAULT false NOT NULL,
    sent_notices boolean DEFAULT false NOT NULL,
    status character varying,
    cancel_message character varying,
    user_decremented boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    default_slot_id character varying(64),
    counter_slot_id character varying(64),
    school_id integer,
    same_school boolean DEFAULT false NOT NULL,
    success boolean,
    sent_notices_at timestamp without time zone,
    countered_at timestamp without time zone,
    counterer_id character varying(64),
    sent_counter_reminder boolean DEFAULT false NOT NULL,
    test_drive_package_id character varying(64),
    test_drive_package_choice_id character varying(64),
    retailer_id integer,
    same_school_free boolean DEFAULT false NOT NULL,
    posa_card_id character varying(64),
    payment character varying,
    same_retailer boolean DEFAULT false NOT NULL,
    posa_card_purchased boolean DEFAULT false NOT NULL,
    remaining_roll_forward_amount_in_cents integer DEFAULT 0 NOT NULL,
    student_canceled boolean DEFAULT false NOT NULL,
    teacher_canceled boolean DEFAULT false NOT NULL,
    student_canceled_at timestamp without time zone,
    teacher_canceled_at timestamp without time zone,
    teacher_canceled_reason character varying,
    student_canceled_reason character varying,
    canceled_by_admin timestamp without time zone
);


--
-- Name: lesson_package_purchases; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.lesson_package_purchases (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    lesson_package_type_id character varying(64) NOT NULL,
    user_id character varying(64) NOT NULL,
    teacher_id character varying(64),
    price numeric(8,2),
    recurring boolean DEFAULT false NOT NULL,
    year integer,
    month integer,
    charge_id character varying(64),
    lesson_booking_id character varying(64),
    sent_notices boolean DEFAULT false NOT NULL,
    sent_notices_at timestamp without time zone,
    post_processed boolean DEFAULT false NOT NULL,
    post_processed_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    posa_card_id character varying(64),
    total_roll_forward_amount_in_cents integer,
    remaining_roll_forward_amount_in_cents integer,
    reduced_roll_forward_amount_in_cents integer DEFAULT 0 NOT NULL,
    expected_session_times integer,
    actual_session_times integer
);


--
-- Name: lesson_package_types; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.lesson_package_types (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying NOT NULL,
    description character varying NOT NULL,
    package_type character varying(64) NOT NULL,
    price numeric(8,2),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    is_test_drive boolean DEFAULT true NOT NULL
);


--
-- Name: lesson_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.lesson_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    lesson_type character varying(64) NOT NULL,
    teacher_id character varying(64) NOT NULL,
    lesson_package_purchase_id character varying(64),
    lesson_booking_id character varying(64),
    duration integer NOT NULL,
    booked_price numeric(8,2) NOT NULL,
    teacher_complete boolean DEFAULT false NOT NULL,
    student_complete boolean DEFAULT false NOT NULL,
    student_canceled boolean DEFAULT false NOT NULL,
    teacher_canceled boolean DEFAULT false NOT NULL,
    student_canceled_at timestamp without time zone,
    teacher_canceled_at timestamp without time zone,
    student_canceled_reason character varying,
    teacher_canceled_reason character varying,
    status character varying,
    analysed boolean DEFAULT false NOT NULL,
    analysis json,
    analysed_at timestamp without time zone,
    cancel_message character varying,
    canceler_id character varying(64),
    charge_id character varying(64),
    success boolean DEFAULT false NOT NULL,
    sent_notices boolean DEFAULT false NOT NULL,
    sent_notices_at timestamp without time zone,
    post_processed boolean DEFAULT false NOT NULL,
    post_processed_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    counter_slot_id character varying(64),
    slot_id character varying(64),
    teacher_unread_messages boolean DEFAULT false NOT NULL,
    student_unread_messages boolean DEFAULT false NOT NULL,
    student_short_canceled boolean DEFAULT false NOT NULL,
    teacher_short_canceled boolean DEFAULT false NOT NULL,
    sent_starting_notice boolean DEFAULT false NOT NULL,
    user_id character varying(64) NOT NULL,
    countered_at timestamp without time zone,
    counterer_id character varying(64),
    admin_marked boolean DEFAULT false NOT NULL,
    sent_counter_reminder boolean DEFAULT false NOT NULL,
    sent_counter_reminder_at timestamp without time zone,
    canceled_by_admin timestamp without time zone,
    intervened_at timestamp without time zone,
    counter_reminders integer DEFAULT 0 NOT NULL,
    sent_early_starting_notice boolean DEFAULT false NOT NULL
);


--
-- Name: likes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.likes (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    likable_id character varying(64) NOT NULL,
    likable_type character varying(25) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: live_streams; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.live_streams (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    slug character varying(512) NOT NULL,
    title text,
    description text,
    social_description text,
    listed boolean DEFAULT false NOT NULL,
    starts_at timestamp without time zone,
    ends_at timestamp without time zone,
    img_url character varying(1024),
    img_width integer,
    img_height integer,
    youtube_code character varying(1024),
    eventbriteid character varying(1024),
    event_type character varying(100),
    event_brite_registration_url character varying(1024),
    allow_in boolean DEFAULT false NOT NULL,
    white_label_player boolean DEFAULT true NOT NULL,
    user_id character varying(64),
    band_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: machine_extras; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.machine_extras (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    machine_fingerprint_id character varying(64) NOT NULL,
    mac_address character varying(100),
    mac_name character varying(255),
    upstate boolean,
    ipaddr_0 character varying(200),
    ipaddr_1 character varying(200),
    ipaddr_2 character varying(200),
    ipaddr_3 character varying(200),
    ipaddr_4 character varying(200),
    ipaddr_5 character varying(200),
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: machine_fingerprints; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.machine_fingerprints (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    fingerprint character varying(20000) NOT NULL,
    when_taken character varying NOT NULL,
    print_type character varying NOT NULL,
    remote_ip character varying(1000) NOT NULL,
    jam_track_right_id bigint,
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: max_mind_releases; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.max_mind_releases (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    released_at date NOT NULL,
    imported boolean DEFAULT false NOT NULL,
    imported_at date,
    geo_ip_124_url character varying(2000),
    geo_ip_124_md5 character varying(255),
    geo_ip_124_size integer,
    geo_ip_134_url character varying(2000),
    geo_ip_134_md5 character varying(255),
    geo_ip_134_size integer,
    region_codes_url character varying(2000),
    region_codes_md5 character varying(255),
    region_codes_size integer,
    iso3166_url character varying(2000),
    iso3166_md5 character varying(255),
    iso3166_size integer,
    table_dumps_url character varying(2000),
    table_dumps_md5 character varying(255),
    table_dumps_size integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: mixes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.mixes (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    recording_id character varying(64) NOT NULL,
    mix_server character varying(64) DEFAULT NULL::character varying,
    started_at timestamp without time zone,
    completed_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ogg_md5 character varying(100),
    ogg_length integer,
    ogg_url character varying(1024),
    completed boolean DEFAULT false NOT NULL,
    error_count integer DEFAULT 0 NOT NULL,
    error_reason text,
    error_detail text,
    should_retry boolean DEFAULT false NOT NULL,
    mp3_md5 character varying(100),
    mp3_length integer,
    mp3_url character varying(1024),
    download_count integer DEFAULT 0 NOT NULL,
    last_downloaded_at timestamp without time zone
);


--
-- Name: mobile_recording_uploads; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.mobile_recording_uploads (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    mobile_recording_id character varying(64) NOT NULL,
    file_url character varying(1024) DEFAULT NULL::character varying,
    file_name character varying(255) DEFAULT NULL::character varying,
    size integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: scores; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.scores (
    alocidispid bigint NOT NULL,
    anodeid character varying(64) NOT NULL,
    aaddr bigint NOT NULL,
    blocidispid bigint NOT NULL,
    bnodeid character varying(64) NOT NULL,
    baddr bigint NOT NULL,
    score integer NOT NULL,
    scorer integer NOT NULL,
    score_dt timestamp without time zone DEFAULT now() NOT NULL,
    scoring_data character varying(4000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    auserid character varying(64),
    buserid character varying(64),
    alatencytestid character varying(64),
    blatencytestid character varying(64)
);


--
-- Name: most_recent_scores; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.most_recent_scores AS
 SELECT s.alocidispid,
    s.anodeid,
    s.aaddr,
    s.blocidispid,
    s.bnodeid,
    s.baddr,
    s.score,
    s.scorer,
    s.score_dt,
    s.scoring_data,
    s.created_at,
    s.auserid,
    s.buserid,
    s.alatencytestid,
    s.blatencytestid
   FROM public.scores s
  WHERE (s.score_dt = ( SELECT max(s0.score_dt) AS max
           FROM public.scores s0
          WHERE ((s0.alocidispid = s.alocidispid) AND (s0.blocidispid = s.blocidispid))));


--
-- Name: music_notations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.music_notations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    music_session_id character varying(64),
    file_url character varying(512) DEFAULT NULL::character varying,
    size integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    file_name character varying(255),
    attachment_type character varying DEFAULT 'notation'::character varying NOT NULL
);


--
-- Name: music_session_perf_data; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.music_session_perf_data (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    music_session_id character varying(64),
    client_id character varying(64),
    uri character varying(1000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: music_sessions_id_int_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.music_sessions_id_int_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: music_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.music_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    music_session_id character varying(64),
    description character varying(8000),
    user_id character varying(64) NOT NULL,
    band_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    session_removed_at timestamp without time zone,
    play_count integer DEFAULT 0 NOT NULL,
    like_count integer DEFAULT 0 NOT NULL,
    fan_access boolean DEFAULT true NOT NULL,
    scheduled_start timestamp without time zone,
    scheduled_duration interval,
    musician_access boolean DEFAULT true NOT NULL,
    approval_required boolean DEFAULT false NOT NULL,
    fan_chat boolean DEFAULT true NOT NULL,
    genre_id character varying(64) NOT NULL,
    legal_policy character varying(255) DEFAULT 'standard'::character varying NOT NULL,
    language character varying(255) DEFAULT 'eng'::character varying NOT NULL,
    name text NOT NULL,
    recurring_session_id character varying(64),
    recurring_mode character varying(50) DEFAULT 'once'::character varying NOT NULL,
    timezone character varying(255),
    started_at timestamp without time zone,
    open_rsvps boolean DEFAULT false NOT NULL,
    next_session_scheduled boolean DEFAULT false,
    description_tsv tsvector,
    is_unstructured_rsvp boolean DEFAULT false,
    canceled boolean DEFAULT false,
    create_type character varying(64),
    session_controller_id character varying(64),
    lesson_session_id character varying(64),
    old boolean DEFAULT false NOT NULL,
    friends_can_join boolean DEFAULT false NOT NULL,
    music_session_id_int integer DEFAULT nextval('public.music_sessions_id_int_seq'::regclass) NOT NULL,
    school_id integer,
    is_platform_instructor boolean DEFAULT false NOT NULL
);


--
-- Name: music_sessions_comments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.music_sessions_comments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    creator_id character varying(64) NOT NULL,
    comment character varying(4000) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ip_address inet,
    music_session_id character varying(64)
);


--
-- Name: music_sessions_likers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.music_sessions_likers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    liker_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ip_address inet,
    music_session_id character varying(64)
);


--
-- Name: music_sessions_user_history; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.music_sessions_user_history (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    client_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    session_removed_at timestamp without time zone,
    max_concurrent_connections integer,
    rating integer,
    instruments character varying(255),
    rating_comment text,
    music_session_id character varying(64),
    backend_details character varying
);


--
-- Name: musicians_instruments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.musicians_instruments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    player_id character varying(64) NOT NULL,
    instrument_id character varying(64) NOT NULL,
    proficiency_level smallint NOT NULL,
    priority smallint DEFAULT 1 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    player_type character varying(32) DEFAULT 'user'::character varying
);


--
-- Name: news; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.news (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    title character varying NOT NULL,
    body character varying NOT NULL,
    "position" integer NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: nondirected_network_scores; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.nondirected_network_scores AS
 WITH recent_scores AS (
         SELECT tmp_1.alocidispid,
            tmp_1.blocidispid,
            tmp_1.score,
            tmp_1.created_at
           FROM ( SELECT scores.alocidispid,
                    scores.anodeid,
                    scores.aaddr,
                    scores.blocidispid,
                    scores.bnodeid,
                    scores.baddr,
                    scores.score,
                    scores.scorer,
                    scores.score_dt,
                    scores.scoring_data,
                    scores.created_at,
                    scores.auserid,
                    scores.buserid,
                    scores.alatencytestid,
                    scores.blatencytestid,
                    row_number() OVER (PARTITION BY scores.alocidispid, scores.blocidispid ORDER BY scores.created_at DESC) AS rownum
                   FROM public.scores) tmp_1
          WHERE ((tmp_1.rownum < 6) AND (tmp_1.scorer = 0))
        ), ranked_scores AS (
         SELECT tmp_1.alocidispid,
            tmp_1.blocidispid,
            tmp_1.score,
            tmp_1.created_at
           FROM ( SELECT percent_rank() OVER (PARTITION BY recent_scores.alocidispid, recent_scores.blocidispid ORDER BY recent_scores.score) AS pc,
                    recent_scores.alocidispid,
                    recent_scores.blocidispid,
                    recent_scores.score,
                    recent_scores.created_at
                   FROM recent_scores) tmp_1
          WHERE (tmp_1.pc <= (0.5)::double precision)
          ORDER BY tmp_1.pc DESC
        ), median_scores AS (
         SELECT tmp_1.alocidispid,
            tmp_1.blocidispid,
            tmp_1.score,
            tmp_1.created_at
           FROM ( SELECT ranked_scores.alocidispid,
                    ranked_scores.blocidispid,
                    ranked_scores.score,
                    ranked_scores.created_at,
                    row_number() OVER (PARTITION BY ranked_scores.alocidispid, ranked_scores.blocidispid ORDER BY ranked_scores.score DESC) AS pc2
                   FROM ranked_scores) tmp_1
          WHERE (tmp_1.pc2 < 2)
        ), forward_scores AS (
         SELECT median_scores.alocidispid AS from_location,
            median_scores.blocidispid AS to_location,
            median_scores.score,
            median_scores.created_at
           FROM median_scores
        ), backward_scores AS (
         SELECT median_scores.blocidispid AS from_location,
            median_scores.alocidispid AS to_location,
            median_scores.score,
            median_scores.created_at
           FROM median_scores
        ), merged_directions AS (
         SELECT forward_scores.from_location,
            forward_scores.to_location,
            forward_scores.score,
            forward_scores.created_at
           FROM forward_scores
        UNION
         SELECT backward_scores.from_location,
            backward_scores.to_location,
            backward_scores.score,
            backward_scores.created_at
           FROM backward_scores
        )
 SELECT tmp.from_location AS alocidispid,
    tmp.to_location AS blocidispid,
    tmp.score,
    tmp.created_at
   FROM ( SELECT merged_directions.from_location,
            merged_directions.to_location,
            merged_directions.score,
            merged_directions.created_at,
            row_number() OVER (PARTITION BY merged_directions.from_location, merged_directions.to_location ORDER BY merged_directions.created_at DESC) AS "row"
           FROM merged_directions) tmp
  WHERE (tmp."row" < 2);


--
-- Name: nondirected_scores; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.nondirected_scores AS
 SELECT nondirected_network_scores.alocidispid,
    nondirected_network_scores.blocidispid,
    nondirected_network_scores.score,
    nondirected_network_scores.created_at,
    a_users.id AS a_userid,
    b_users.id AS b_userid,
    ((COALESCE(a_users.last_jam_audio_latency, (13)::double precision) + COALESCE(b_users.last_jam_audio_latency, (13)::double precision)) + (nondirected_network_scores.score)::double precision) AS full_score,
    a_users.last_jam_audio_latency AS a_audio_latency,
    b_users.last_jam_audio_latency AS b_audio_latency
   FROM ((public.nondirected_network_scores
     JOIN public.users a_users ON ((a_users.last_jam_locidispid = nondirected_network_scores.alocidispid)))
     JOIN public.users b_users ON ((b_users.last_jam_locidispid = nondirected_network_scores.blocidispid)))
  ORDER BY ((COALESCE(a_users.last_jam_audio_latency, (13)::double precision) + COALESCE(b_users.last_jam_audio_latency, (13)::double precision)) + (nondirected_network_scores.score)::double precision);


--
-- Name: notifications; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.notifications (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    description character varying(100) NOT NULL,
    source_user_id character varying(64),
    target_user_id character varying(64),
    band_id character varying(64),
    session_id character varying(64),
    recording_id character varying(64),
    invitation_id character varying(64),
    join_request_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    friend_request_id character varying(64),
    band_invitation_id character varying(64),
    message text,
    jam_track_right_id bigint,
    jam_track_mixdown_package_id character varying(64),
    lesson_session_id character varying(64),
    purpose character varying(200),
    student_directed boolean
);


--
-- Name: online_presences; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.online_presences (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    player_id character varying(64) NOT NULL,
    service_type character varying(100) NOT NULL,
    username character varying(100) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    player_type character varying(32) DEFAULT 'user'::character varying
);


--
-- Name: recurly_transaction_web_hooks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recurly_transaction_web_hooks (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    recurly_transaction_id character varying NOT NULL,
    transaction_type character varying NOT NULL,
    subscription_id character varying,
    action character varying NOT NULL,
    status character varying NOT NULL,
    amount_in_cents integer,
    user_id character varying(64) NOT NULL,
    invoice_id character varying,
    invoice_number_prefix character varying,
    invoice_number integer,
    message character varying,
    reference character varying,
    transaction_at timestamp without time zone NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    admin_description character varying,
    jam_track_id character varying(64)
);


--
-- Name: sales; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sales (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    order_total numeric DEFAULT 0 NOT NULL,
    shipping_info json,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    recurly_invoice_id character varying(500),
    recurly_invoice_number integer,
    recurly_subtotal_in_cents integer,
    recurly_tax_in_cents integer,
    recurly_total_in_cents integer,
    recurly_currency character varying,
    sale_type character varying DEFAULT 'jamtrack'::character varying NOT NULL,
    source character varying DEFAULT 'recurly'::character varying NOT NULL,
    stripe_charge_id character varying(200),
    retailer_id integer
);


--
-- Name: payment_histories; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.payment_histories AS
 SELECT s.id AS sale_id,
    NULL::character varying AS recurly_transaction_web_hook_id,
    s.user_id,
    s.created_at,
    'sale'::character varying AS transaction_type
   FROM public.sales s
UNION ALL
 SELECT NULL::character varying AS sale_id,
    recurly_transaction_web_hooks.id AS recurly_transaction_web_hook_id,
    recurly_transaction_web_hooks.user_id,
    recurly_transaction_web_hooks.transaction_at AS created_at,
    recurly_transaction_web_hooks.transaction_type
   FROM public.recurly_transaction_web_hooks;


--
-- Name: performance_samples; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.performance_samples (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    player_id character varying(64) NOT NULL,
    url character varying(4000),
    service_type character varying(100) NOT NULL,
    claimed_recording_id character varying(64),
    service_id character varying(100),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    description character varying(256),
    player_type character varying(32) DEFAULT 'user'::character varying
);


--
-- Name: playable_plays; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.playable_plays (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    playable_id character varying(64),
    playable_type character varying(128),
    player_id character varying(64),
    claimed_recording_id character varying(64),
    ip_address inet,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: posa_card_purchases; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.posa_card_purchases (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    posa_card_type_id character varying(64),
    posa_card_id character varying(64),
    recurly_adjustment_uuid character varying(500),
    recurly_adjustment_credit_uuid character varying(500),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: posa_card_types; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.posa_card_types (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    card_type character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: posa_cards; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.posa_cards (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    code character varying(64) NOT NULL,
    user_id character varying(64),
    card_type character varying(64) NOT NULL,
    origin character varying(200),
    activated_at timestamp without time zone,
    claimed_at timestamp without time zone,
    retailer_id integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    lesson_package_type_id character varying(64),
    credits integer DEFAULT 1 NOT NULL,
    is_lesson boolean DEFAULT false NOT NULL,
    preactivate boolean DEFAULT false NOT NULL,
    requires_purchase boolean DEFAULT false NOT NULL,
    purchased boolean DEFAULT true NOT NULL,
    is_test boolean DEFAULT false
);


--
-- Name: promotionals; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.promotionals (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    type character varying(128) DEFAULT 'JamRuby::PromoBuzz'::character varying NOT NULL,
    aasm_state character varying(64) DEFAULT 'hidden'::character varying,
    "position" integer DEFAULT 0 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    latest_id character varying(64) DEFAULT NULL::character varying,
    latest_type character varying(128) DEFAULT NULL::character varying,
    image character varying(1024) DEFAULT NULL::character varying,
    text_short character varying(512) DEFAULT NULL::character varying,
    text_long character varying(4096) DEFAULT NULL::character varying
);


--
-- Name: quick_mixes; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.quick_mixes (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    next_part_to_upload integer DEFAULT 0 NOT NULL,
    fully_uploaded boolean DEFAULT false NOT NULL,
    upload_id character varying(1024),
    file_offset bigint DEFAULT 0,
    is_part_uploading boolean DEFAULT false NOT NULL,
    upload_failures integer DEFAULT 0,
    part_failures integer DEFAULT 0,
    ogg_md5 character varying(100),
    ogg_length integer,
    ogg_url character varying(1000),
    mp3_md5 character varying(100),
    mp3_length integer,
    mp3_url character varying(1000),
    error_count integer DEFAULT 0 NOT NULL,
    error_reason text,
    error_detail text,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    started_at timestamp without time zone,
    completed_at timestamp without time zone,
    completed boolean DEFAULT false NOT NULL,
    should_retry boolean DEFAULT false NOT NULL,
    cleaned boolean DEFAULT false NOT NULL,
    user_id character varying(64),
    recording_id character varying(64)
);


--
-- Name: recorded_backing_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recorded_backing_tracks (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    user_id character varying(64),
    backing_track_id character varying(64),
    recording_id character varying(64) NOT NULL,
    client_track_id character varying(64) NOT NULL,
    is_part_uploading boolean DEFAULT false NOT NULL,
    next_part_to_upload integer DEFAULT 0 NOT NULL,
    upload_id character varying(1024),
    part_failures integer DEFAULT 0 NOT NULL,
    discard boolean,
    download_count integer DEFAULT 0 NOT NULL,
    md5 character varying(100),
    length bigint,
    client_id character varying(64) NOT NULL,
    file_offset bigint,
    url character varying(1024) NOT NULL,
    fully_uploaded boolean DEFAULT false NOT NULL,
    upload_failures integer DEFAULT 0 NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    filename character varying NOT NULL,
    last_downloaded_at timestamp without time zone
);


--
-- Name: recorded_jam_track_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recorded_jam_track_tracks (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    user_id character varying(64) NOT NULL,
    jam_track_track_id character varying(64) NOT NULL,
    recording_id character varying(64) NOT NULL,
    discard boolean,
    timeline json,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: recorded_tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recorded_tracks (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    user_id character varying(64) NOT NULL,
    instrument_id character varying(64) NOT NULL,
    sound character varying(64) NOT NULL,
    next_part_to_upload integer DEFAULT 0 NOT NULL,
    fully_uploaded boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    upload_id character varying(1024),
    recording_id character varying(64) NOT NULL,
    md5 character varying(100),
    length bigint,
    client_id character varying(64) NOT NULL,
    track_id character varying(64) NOT NULL,
    url character varying(1024),
    file_offset bigint DEFAULT 0,
    client_track_id character varying(64) NOT NULL,
    is_part_uploading boolean DEFAULT false NOT NULL,
    upload_failures integer DEFAULT 0 NOT NULL,
    part_failures integer DEFAULT 0 NOT NULL,
    discard boolean,
    download_count integer DEFAULT 0 NOT NULL,
    last_downloaded_at timestamp without time zone
);


--
-- Name: recorded_videos; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recorded_videos (
    id bigint DEFAULT nextval('public.tracks_next_tracker_seq'::regclass) NOT NULL,
    user_id character varying(64),
    fully_uploaded boolean DEFAULT false NOT NULL,
    recording_id character varying(64) NOT NULL,
    length bigint,
    client_video_source_id character varying(64) NOT NULL,
    url character varying(1024),
    file_offset bigint,
    upload_failures integer DEFAULT 0 NOT NULL,
    discard boolean,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: recordings; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recordings (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    owner_id character varying(64) NOT NULL,
    music_session_id character varying(64),
    band_id character varying(64),
    duration integer,
    is_done boolean DEFAULT false,
    all_discarded boolean DEFAULT false NOT NULL,
    name character varying(1024),
    play_count integer DEFAULT 0 NOT NULL,
    like_count integer DEFAULT 0 NOT NULL,
    has_stream_mix boolean DEFAULT false NOT NULL,
    has_final_mix boolean DEFAULT false NOT NULL,
    first_quick_mix_id bigint,
    deleted boolean DEFAULT false NOT NULL,
    jam_track_id character varying(64),
    jam_track_initiator_id character varying(64),
    timeline json,
    video boolean DEFAULT false NOT NULL,
    external_video_id character varying,
    immediate boolean DEFAULT false,
    school_id integer,
    is_platform_instructor boolean DEFAULT false NOT NULL
);


--
-- Name: recordings_comments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recordings_comments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    recording_id character varying(64) NOT NULL,
    creator_id character varying(64) NOT NULL,
    comment character varying(4000) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ip_address inet
);


--
-- Name: recordings_downloads; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recordings_downloads (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    recording_id character varying(64) NOT NULL,
    downloader_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: recordings_likers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recordings_likers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    recording_id character varying(64) NOT NULL,
    liker_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    ip_address inet,
    claimed_recording_id character varying(64) NOT NULL,
    favorite boolean DEFAULT true NOT NULL
);


--
-- Name: recurring_sessions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.recurring_sessions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    description character varying(8000),
    scheduled_start timestamp with time zone,
    scheduled_duration interval,
    musician_access boolean NOT NULL,
    approval_required boolean NOT NULL,
    fan_chat boolean NOT NULL,
    genre_id character varying(64),
    legal_policy character varying(255) DEFAULT 'standard'::character varying NOT NULL,
    language character varying(255) DEFAULT 'en'::character varying NOT NULL,
    name text,
    user_id character varying(64) NOT NULL,
    band_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: regions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.regions (
    region character varying(2) NOT NULL,
    regionname character varying(64),
    countrycode character varying(2) NOT NULL
);


--
-- Name: retailer_invitations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.retailer_invitations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    retailer_id integer NOT NULL,
    invitation_code character varying(256) NOT NULL,
    note character varying,
    email character varying NOT NULL,
    first_name character varying,
    last_name character varying,
    accepted boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: retailer_key_sequence; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.retailer_key_sequence
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: retailers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.retailers (
    id integer DEFAULT nextval('public.retailer_key_sequence'::regclass) NOT NULL,
    user_id character varying(64) NOT NULL,
    name character varying,
    enabled boolean DEFAULT true,
    city character varying,
    state character varying,
    slug character varying,
    encrypted_password character varying DEFAULT public.uuid_generate_v4() NOT NULL,
    photo_url character varying(2048),
    original_fpfile character varying(8000),
    cropped_fpfile character varying(8000),
    cropped_s3_path character varying(8000),
    crop_selection character varying(256),
    large_photo_url character varying(512),
    cropped_large_s3_path character varying(512),
    cropped_large_fpfile character varying(8000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    jamkazam_rate numeric(8,2) DEFAULT 0.25,
    affiliate_partner_id integer,
    payment character varying,
    special character varying
);


--
-- Name: review_summaries; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.review_summaries (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    target_id character varying(64) NOT NULL,
    target_type character varying(32) NOT NULL,
    avg_rating double precision NOT NULL,
    wilson_score double precision NOT NULL,
    review_count integer NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: reviews; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.reviews (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    target_id character varying(64) NOT NULL,
    target_type character varying(32) NOT NULL,
    description character varying,
    rating integer NOT NULL,
    deleted_by_user_id character varying(64),
    deleted_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: rsvp_requests; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.rsvp_requests (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    canceled boolean DEFAULT false,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    cancel_all boolean DEFAULT false,
    music_session_id character varying(64),
    chosen boolean DEFAULT false NOT NULL
);


--
-- Name: rsvp_requests_rsvp_slots; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.rsvp_requests_rsvp_slots (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    rsvp_request_id character varying(64) NOT NULL,
    rsvp_slot_id character varying(64) NOT NULL,
    chosen boolean,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: rsvp_slots; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.rsvp_slots (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    instrument_id character varying(64),
    proficiency_level smallint,
    music_session_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    is_unstructured_rsvp boolean DEFAULT false
);


--
-- Name: sale_line_items; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.sale_line_items (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    product_type character varying NOT NULL,
    product_id character varying(64),
    unit_price numeric NOT NULL,
    quantity integer NOT NULL,
    free integer NOT NULL,
    sales_tax numeric,
    shipping_handling numeric NOT NULL,
    recurly_plan_code character varying NOT NULL,
    recurly_subscription_uuid character varying,
    sale_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    recurly_adjustment_uuid character varying(500),
    recurly_adjustment_credit_uuid character varying(500),
    recurly_tax_in_cents integer,
    recurly_total_in_cents integer,
    recurly_currency character varying,
    recurly_discount_in_cents integer,
    affiliate_referral_id integer,
    affiliate_referral_fee_in_cents integer,
    affiliate_refunded boolean DEFAULT false NOT NULL,
    affiliate_refunded_at timestamp without time zone,
    gift_card_purchase_id character varying(64),
    lesson_package_purchase_id character varying(64),
    posa_card_purchase_id character varying(64),
    retailer_id integer,
    variant character varying
);


--
-- Name: school_invitations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.school_invitations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    school_id integer NOT NULL,
    invitation_code character varying(256) NOT NULL,
    note character varying,
    as_teacher boolean NOT NULL,
    email character varying NOT NULL,
    first_name character varying,
    last_name character varying,
    accepted boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: school_key_sequence; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE public.school_key_sequence
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: schools; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.schools (
    id integer DEFAULT nextval('public.school_key_sequence'::regclass) NOT NULL,
    user_id character varying(64) NOT NULL,
    name character varying,
    enabled boolean DEFAULT true,
    scheduling_communication character varying DEFAULT 'teacher'::character varying NOT NULL,
    correspondence_email character varying,
    photo_url character varying(2048),
    original_fpfile character varying(8000),
    cropped_fpfile character varying(8000),
    cropped_s3_path character varying(8000),
    crop_selection character varying(256),
    large_photo_url character varying(512),
    cropped_large_s3_path character varying(512),
    cropped_large_fpfile character varying(8000),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    jamkazam_rate numeric(8,2) DEFAULT 0.20,
    affiliate_partner_id integer,
    education boolean DEFAULT false NOT NULL,
    special character varying,
    base_rate numeric(8,2) DEFAULT 0.10,
    school_tag character varying(100)
);


--
-- Name: score_histories; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.score_histories (
    from_client_id character varying(64),
    from_addr bigint,
    from_isp character varying(50),
    from_country character varying(64),
    from_region character varying(64),
    from_city character varying(255),
    from_postal character varying(25),
    from_latitude double precision,
    from_longitude double precision,
    to_client_id character varying(64),
    to_addr bigint,
    to_isp character varying(50),
    to_country character varying(64),
    to_region character varying(64),
    to_city character varying(255),
    to_postal character varying(25),
    to_latitude double precision,
    to_longitude double precision,
    score integer NOT NULL,
    score_dt timestamp without time zone NOT NULL,
    scoring_data text,
    from_user_id character varying(64),
    to_user_id character varying(64),
    from_latency_tester_id character varying(64),
    to_latency_tester_id character varying(64),
    from_locidispid bigint NOT NULL,
    to_locidispid bigint NOT NULL
);


--
-- Name: session_info_comments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.session_info_comments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    music_session_id character varying(64) NOT NULL,
    creator_id character varying(64) NOT NULL,
    comment text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: share_tokens; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.share_tokens (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    token character varying(15) NOT NULL,
    shareable_id character varying(64) NOT NULL,
    shareable_type character varying(50) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: shopping_carts; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.shopping_carts (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    quantity integer DEFAULT 1 NOT NULL,
    user_id character varying(64),
    cart_id character varying(64) NOT NULL,
    cart_class_name character varying(64),
    cart_type character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    anonymous_user_id character varying(1000),
    marked_for_redeem integer DEFAULT 0 NOT NULL,
    variant character varying
);


--
-- Name: signup_hints; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.signup_hints (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    anonymous_user_id character varying(64),
    redirect_location character varying,
    want_jamblaster boolean DEFAULT false NOT NULL,
    user_id character varying(64),
    expires_at timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: subjects; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.subjects (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    description character varying(1024)
);


--
-- Name: teacher_distributions; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teacher_distributions (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    teacher_id character varying(64) NOT NULL,
    teacher_payment_id character varying(64),
    lesson_session_id character varying(64),
    lesson_package_purchase_id character varying(64),
    amount_in_cents integer NOT NULL,
    ready boolean DEFAULT false NOT NULL,
    distributed boolean DEFAULT false NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    school_id integer,
    retailer_id integer,
    education boolean DEFAULT false NOT NULL,
    teacher_fee_in_cents integer,
    reduced_roll_forward_amount_in_cents integer DEFAULT 0 NOT NULL
);


--
-- Name: teacher_experiences; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teacher_experiences (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    teacher_id character varying(64),
    experience_type character varying(32) NOT NULL,
    name character varying(200) NOT NULL,
    organization character varying(200) NOT NULL,
    start_year smallint DEFAULT 0 NOT NULL,
    end_year smallint
);


--
-- Name: teacher_intents; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teacher_intents (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    teacher_id character varying(64) NOT NULL,
    intent character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: teacher_payments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teacher_payments (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    teacher_id character varying(64) NOT NULL,
    charge_id character varying(64) NOT NULL,
    amount_in_cents integer NOT NULL,
    fee_in_cents integer NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    school_id integer,
    retailer_id integer
);


--
-- Name: teachers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teachers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    introductory_video character varying(1024),
    years_teaching smallint DEFAULT 0 NOT NULL,
    years_playing smallint DEFAULT 0 NOT NULL,
    teaches_age_lower smallint DEFAULT 0 NOT NULL,
    teaches_age_upper smallint DEFAULT 0 NOT NULL,
    teaches_beginner boolean DEFAULT false NOT NULL,
    teaches_intermediate boolean DEFAULT false NOT NULL,
    teaches_advanced boolean DEFAULT false NOT NULL,
    website character varying(1024),
    biography character varying(4096),
    prices_per_lesson boolean DEFAULT false NOT NULL,
    prices_per_month boolean DEFAULT false NOT NULL,
    lesson_duration_30 boolean DEFAULT false NOT NULL,
    lesson_duration_45 boolean DEFAULT false NOT NULL,
    lesson_duration_60 boolean DEFAULT false NOT NULL,
    lesson_duration_90 boolean DEFAULT false NOT NULL,
    lesson_duration_120 boolean DEFAULT false NOT NULL,
    price_per_lesson_30_cents integer,
    price_per_lesson_45_cents integer,
    price_per_lesson_60_cents integer,
    price_per_lesson_90_cents integer,
    price_per_lesson_120_cents integer,
    price_per_month_30_cents integer,
    price_per_month_45_cents integer,
    price_per_month_60_cents integer,
    price_per_month_90_cents integer,
    price_per_month_120_cents integer,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    test_drives_per_week integer DEFAULT 2 NOT NULL,
    teaches_test_drive boolean DEFAULT true NOT NULL,
    background_check_at timestamp without time zone,
    ready_for_session_at timestamp without time zone,
    top_rated boolean DEFAULT false NOT NULL,
    profile_pct numeric(8,2),
    profile_pct_summary json,
    school_id integer,
    joined_school_at timestamp without time zone,
    jamkazam_rate numeric(8,2) DEFAULT 0.25,
    short_bio character varying,
    retailer_id integer,
    joined_retailer_at timestamp without time zone,
    is_searchable boolean DEFAULT true NOT NULL,
    random_order integer DEFAULT 0 NOT NULL
);


--
-- Name: teachers_genres; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teachers_genres (
    teacher_id character varying(64),
    genre_id character varying(64)
);


--
-- Name: teachers_instruments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teachers_instruments (
    teacher_id character varying(64),
    instrument_id character varying(64)
);


--
-- Name: teachers_languages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teachers_languages (
    teacher_id character varying(64),
    language_id character varying(64)
);


--
-- Name: teachers_subjects; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.teachers_subjects (
    teacher_id character varying(64),
    subject_id character varying(64)
);


--
-- Name: test_drive_package_choice_teachers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.test_drive_package_choice_teachers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    test_drive_package_choice_id character varying(64),
    teacher_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: test_drive_package_choices; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.test_drive_package_choices (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    test_drive_package_id character varying(64),
    user_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: test_drive_package_teachers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.test_drive_package_teachers (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    test_drive_package_id character varying(64),
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    short_bio character varying
);


--
-- Name: test_drive_packages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.test_drive_packages (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    name character varying NOT NULL,
    package_type character varying NOT NULL,
    description character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: text_messages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.text_messages (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    source_user_id character varying(64),
    target_user_id character varying(64),
    message text NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: tracks; Type: TABLE; Schema: public; Owner: -
--

CREATE UNLOGGED TABLE public.tracks (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    connection_id character varying(64) NOT NULL,
    instrument_id character varying(64),
    sound character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    client_track_id character varying(64) NOT NULL,
    client_resource_id character varying(100)
);


--
-- Name: user_authorizations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_authorizations (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    uid character varying(255) NOT NULL,
    provider character varying(255) NOT NULL,
    token character varying(2000),
    token_expiration timestamp without time zone,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL,
    secret character varying(255),
    refresh_token character varying
);


--
-- Name: user_blacklists; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_blacklists (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    notes character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: user_events; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_events (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64),
    name character varying(100) NOT NULL,
    detail json,
    created_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: user_syncs; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW public.user_syncs AS
 SELECT DISTINCT b.id AS recorded_track_id,
    NULL::bigint AS mix_id,
    NULL::bigint AS quick_mix_id,
    NULL::bigint AS recorded_backing_track_id,
    b.id AS unified_id,
    a.user_id,
    b.fully_uploaded,
    recordings.created_at,
    recordings.id AS recording_id
   FROM ((public.recorded_tracks a
     JOIN public.recordings ON ((((((a.recording_id)::text = (recordings.id)::text) AND (recordings.duration IS NOT NULL)) AND (recordings.all_discarded = false)) AND (recordings.deleted = false))))
     JOIN public.recorded_tracks b ON (((a.recording_id)::text = (b.recording_id)::text)))
UNION ALL
 SELECT NULL::bigint AS recorded_track_id,
    NULL::bigint AS mix_id,
    NULL::bigint AS quick_mix_id,
    a.id AS recorded_backing_track_id,
    a.id AS unified_id,
    a.user_id,
    a.fully_uploaded,
    recordings.created_at,
    recordings.id AS recording_id
   FROM (public.recorded_backing_tracks a
     JOIN public.recordings ON ((((((a.recording_id)::text = (recordings.id)::text) AND (recordings.duration IS NOT NULL)) AND (recordings.all_discarded = false)) AND (recordings.deleted = false))))
UNION ALL
 SELECT NULL::bigint AS recorded_track_id,
    mixes.id AS mix_id,
    NULL::bigint AS quick_mix_id,
    NULL::bigint AS recorded_backing_track_id,
    mixes.id AS unified_id,
    claimed_recordings.user_id,
    NULL::boolean AS fully_uploaded,
    recordings.created_at,
    recordings.id AS recording_id
   FROM ((public.mixes
     JOIN public.recordings ON (((mixes.recording_id)::text = (recordings.id)::text)))
     JOIN public.claimed_recordings ON (((recordings.id)::text = (claimed_recordings.recording_id)::text)))
  WHERE ((claimed_recordings.discarded = false) AND (recordings.deleted = false))
UNION ALL
 SELECT NULL::bigint AS recorded_track_id,
    NULL::bigint AS mix_id,
    quick_mixes.id AS quick_mix_id,
    NULL::bigint AS recorded_backing_track_id,
    quick_mixes.id AS unified_id,
    quick_mixes.user_id,
    quick_mixes.fully_uploaded,
    recordings.created_at,
    recordings.id AS recording_id
   FROM (public.quick_mixes
     JOIN public.recordings ON ((((((quick_mixes.recording_id)::text = (recordings.id)::text) AND (recordings.duration IS NOT NULL)) AND (recordings.all_discarded = false)) AND (recordings.deleted = false))));


--
-- Name: user_whitelists; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.user_whitelists (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    user_id character varying(64) NOT NULL,
    notes character varying,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: video_sources; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.video_sources (
    id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL,
    connection_id character varying(64) NOT NULL,
    client_video_source_id character varying(64) NOT NULL,
    created_at timestamp without time zone DEFAULT now() NOT NULL,
    updated_at timestamp without time zone DEFAULT now() NOT NULL
);


--
-- Name: pg_migrate id; Type: DEFAULT; Schema: pgmigrate; Owner: -
--

ALTER TABLE ONLY pgmigrate.pg_migrate ALTER COLUMN id SET DEFAULT nextval('pgmigrate.pg_migrate_id_seq'::regclass);


--
-- Name: active_admin_comments id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.active_admin_comments ALTER COLUMN id SET DEFAULT nextval('public.active_admin_comments_id_seq'::regclass);


--
-- Name: feeds id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.feeds ALTER COLUMN id SET DEFAULT nextval('public.feeds_id_seq'::regclass);


--
-- Name: jam_track_hfa_requests id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_hfa_requests ALTER COLUMN id SET DEFAULT nextval('public.jam_track_hfa_requests_id_seq'::regclass);


--
-- Name: jamcompany coid; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamcompany ALTER COLUMN coid SET DEFAULT nextval('public.jamcompany_coid_seq'::regclass);


--
-- Name: pg_migrate pg_migrate_pkey; Type: CONSTRAINT; Schema: pgmigrate; Owner: -
--

ALTER TABLE ONLY pgmigrate.pg_migrate
    ADD CONSTRAINT pg_migrate_pkey PRIMARY KEY (id);


--
-- Name: pg_migrations pg_migrations_pkey; Type: CONSTRAINT; Schema: pgmigrate; Owner: -
--

ALTER TABLE ONLY pgmigrate.pg_migrations
    ADD CONSTRAINT pg_migrations_pkey PRIMARY KEY (name);


--
-- Name: active_admin_comments admin_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.active_admin_comments
    ADD CONSTRAINT admin_comments_pkey PRIMARY KEY (id);


--
-- Name: affiliate_distributions affiliate_distributions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_distributions
    ADD CONSTRAINT affiliate_distributions_pkey PRIMARY KEY (id);


--
-- Name: affiliate_legalese affiliate_legalese_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_legalese
    ADD CONSTRAINT affiliate_legalese_pkey PRIMARY KEY (id);


--
-- Name: affiliate_monthly_payments affiliate_monthly_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_monthly_payments
    ADD CONSTRAINT affiliate_monthly_payments_pkey PRIMARY KEY (id);


--
-- Name: affiliate_partners affiliate_partners_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_partners
    ADD CONSTRAINT affiliate_partners_pkey PRIMARY KEY (id);


--
-- Name: affiliate_partners affiliate_partners_special_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_partners
    ADD CONSTRAINT affiliate_partners_special_key UNIQUE (special);


--
-- Name: affiliate_quarterly_payments affiliate_quarterly_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_quarterly_payments
    ADD CONSTRAINT affiliate_quarterly_payments_pkey PRIMARY KEY (id);


--
-- Name: affiliate_referral_visits affiliate_referral_visits_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_referral_visits
    ADD CONSTRAINT affiliate_referral_visits_pkey PRIMARY KEY (id);


--
-- Name: arses arses_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arses
    ADD CONSTRAINT arses_name_key UNIQUE (name);


--
-- Name: arses arses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.arses
    ADD CONSTRAINT arses_pkey PRIMARY KEY (id);


--
-- Name: artifact_updates artifact_updates_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.artifact_updates
    ADD CONSTRAINT artifact_updates_uniqkey UNIQUE (product, version);


--
-- Name: backing_tracks backing_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.backing_tracks
    ADD CONSTRAINT backing_tracks_pkey PRIMARY KEY (id);


--
-- Name: band_invitations band_invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.band_invitations
    ADD CONSTRAINT band_invitations_pkey PRIMARY KEY (id);


--
-- Name: bands_musicians band_musician_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bands_musicians
    ADD CONSTRAINT band_musician_uniqkey UNIQUE (band_id, user_id);


--
-- Name: genre_players bands_genres_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genre_players
    ADD CONSTRAINT bands_genres_pkey PRIMARY KEY (id);


--
-- Name: bands_musicians bands_musicians_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bands_musicians
    ADD CONSTRAINT bands_musicians_pkey PRIMARY KEY (id);


--
-- Name: bands bands_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bands
    ADD CONSTRAINT bands_pkey PRIMARY KEY (id);


--
-- Name: broadcast_notification_views broadcast_notification_views_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcast_notification_views
    ADD CONSTRAINT broadcast_notification_views_pkey PRIMARY KEY (id);


--
-- Name: broadcast_notifications broadcast_notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcast_notifications
    ADD CONSTRAINT broadcast_notifications_pkey PRIMARY KEY (id);


--
-- Name: broadcasts broadcasts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcasts
    ADD CONSTRAINT broadcasts_pkey PRIMARY KEY (id);


--
-- Name: calendars calendars_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.calendars
    ADD CONSTRAINT calendars_pkey PRIMARY KEY (id);


--
-- Name: campaign_spends campaign_spends_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.campaign_spends
    ADD CONSTRAINT campaign_spends_pkey PRIMARY KEY (id);


--
-- Name: charges charges_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.charges
    ADD CONSTRAINT charges_pkey PRIMARY KEY (id);


--
-- Name: chat_messages chat_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_pkey PRIMARY KEY (id);


--
-- Name: claimed_recordings claimed_recordings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.claimed_recordings
    ADD CONSTRAINT claimed_recordings_pkey PRIMARY KEY (id);


--
-- Name: client_live_streams client_live_streams_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.client_live_streams
    ADD CONSTRAINT client_live_streams_pkey PRIMARY KEY (id);


--
-- Name: cohorts cohorts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.cohorts
    ADD CONSTRAINT cohorts_pkey PRIMARY KEY (id);


--
-- Name: connections connections_client_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.connections
    ADD CONSTRAINT connections_client_id_key UNIQUE (client_id);


--
-- Name: connections connections_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.connections
    ADD CONSTRAINT connections_pkey PRIMARY KEY (id);


--
-- Name: crash_dumps crash_dumps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.crash_dumps
    ADD CONSTRAINT crash_dumps_pkey PRIMARY KEY (id);


--
-- Name: download_trackers download_trackers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.download_trackers
    ADD CONSTRAINT download_trackers_pkey PRIMARY KEY (id);


--
-- Name: email_batch_sets email_batch_set_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_batch_sets
    ADD CONSTRAINT email_batch_set_uniqkey UNIQUE (email_batch_id, started_at);


--
-- Name: email_batch_sets email_batch_sets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_batch_sets
    ADD CONSTRAINT email_batch_sets_pkey PRIMARY KEY (id);


--
-- Name: email_batches email_batches_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_batches
    ADD CONSTRAINT email_batches_pkey PRIMARY KEY (id);


--
-- Name: email_blacklists email_blacklists_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_blacklists
    ADD CONSTRAINT email_blacklists_email_key UNIQUE (email);


--
-- Name: email_blacklists email_blacklists_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_blacklists
    ADD CONSTRAINT email_blacklists_pkey PRIMARY KEY (id);


--
-- Name: email_errors email_errors_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_errors
    ADD CONSTRAINT email_errors_pkey PRIMARY KEY (id);


--
-- Name: event_brite_order_uploads event_brite_order_uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_brite_order_uploads
    ADD CONSTRAINT event_brite_order_uploads_pkey PRIMARY KEY (id);


--
-- Name: event_brite_orders event_brite_orders_order_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_brite_orders
    ADD CONSTRAINT event_brite_orders_order_id_key UNIQUE (order_id);


--
-- Name: event_brite_orders event_brite_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_brite_orders
    ADD CONSTRAINT event_brite_orders_pkey PRIMARY KEY (id);


--
-- Name: event_sessions event_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_sessions
    ADD CONSTRAINT event_sessions_pkey PRIMARY KEY (id);


--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.events
    ADD CONSTRAINT events_pkey PRIMARY KEY (id);


--
-- Name: events events_slug_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.events
    ADD CONSTRAINT events_slug_key UNIQUE (slug);


--
-- Name: facebook_signups facebook_signups_lookup_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.facebook_signups
    ADD CONSTRAINT facebook_signups_lookup_id_key UNIQUE (lookup_id);


--
-- Name: facebook_signups facebook_signups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.facebook_signups
    ADD CONSTRAINT facebook_signups_pkey PRIMARY KEY (id);


--
-- Name: fan_invitations fan_invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fan_invitations
    ADD CONSTRAINT fan_invitations_pkey PRIMARY KEY (id);


--
-- Name: feeds feeds_music_session_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_music_session_id_key UNIQUE (music_session_id);


--
-- Name: feeds feeds_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_pkey PRIMARY KEY (id);


--
-- Name: feeds feeds_recording_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_recording_id_key UNIQUE (recording_id);


--
-- Name: fingerprint_whitelists fingerprint_whitelists_fingerprint_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fingerprint_whitelists
    ADD CONSTRAINT fingerprint_whitelists_fingerprint_key UNIQUE (fingerprint);


--
-- Name: fingerprint_whitelists fingerprint_whitelists_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fingerprint_whitelists
    ADD CONSTRAINT fingerprint_whitelists_pkey PRIMARY KEY (id);


--
-- Name: follows follows_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.follows
    ADD CONSTRAINT follows_pkey PRIMARY KEY (id);


--
-- Name: follows follows_user_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.follows
    ADD CONSTRAINT follows_user_uniqkey UNIQUE (user_id, followable_id);


--
-- Name: fraud_alerts fraud_alerts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fraud_alerts
    ADD CONSTRAINT fraud_alerts_pkey PRIMARY KEY (id);


--
-- Name: friend_requests friend_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friend_requests
    ADD CONSTRAINT friend_requests_pkey PRIMARY KEY (id);


--
-- Name: friendships friendships_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friendships
    ADD CONSTRAINT friendships_pkey PRIMARY KEY (id);


--
-- Name: generic_state generic_state_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.generic_state
    ADD CONSTRAINT generic_state_pkey PRIMARY KEY (id);


--
-- Name: genre_players genre_player_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genre_players
    ADD CONSTRAINT genre_player_uniqkey UNIQUE (player_id, player_type, genre_id, genre_type);


--
-- Name: genres_jam_tracks genres_jam_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genres_jam_tracks
    ADD CONSTRAINT genres_jam_tracks_pkey PRIMARY KEY (id);


--
-- Name: genres_music_sessions genres_music_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genres_music_sessions
    ADD CONSTRAINT genres_music_sessions_pkey PRIMARY KEY (id);


--
-- Name: genres genres_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genres
    ADD CONSTRAINT genres_pkey PRIMARY KEY (id);


--
-- Name: geoiplocations geoiplocations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.geoiplocations
    ADD CONSTRAINT geoiplocations_pkey PRIMARY KEY (locid);


--
-- Name: gift_card_purchases gift_card_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_card_purchases
    ADD CONSTRAINT gift_card_purchases_pkey PRIMARY KEY (id);


--
-- Name: gift_card_types gift_card_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_card_types
    ADD CONSTRAINT gift_card_types_pkey PRIMARY KEY (id);


--
-- Name: gift_cards gift_cards_code_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_cards
    ADD CONSTRAINT gift_cards_code_key UNIQUE (code);


--
-- Name: gift_cards gift_cards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_cards
    ADD CONSTRAINT gift_cards_pkey PRIMARY KEY (id);


--
-- Name: icecast_admin_authentications icecast_admin_authentications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_admin_authentications
    ADD CONSTRAINT icecast_admin_authentications_pkey PRIMARY KEY (id);


--
-- Name: icecast_directories icecast_directories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_directories
    ADD CONSTRAINT icecast_directories_pkey PRIMARY KEY (id);


--
-- Name: icecast_limits icecast_limits_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_limits
    ADD CONSTRAINT icecast_limits_pkey PRIMARY KEY (id);


--
-- Name: icecast_listen_sockets icecast_listen_sockets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_listen_sockets
    ADD CONSTRAINT icecast_listen_sockets_pkey PRIMARY KEY (id);


--
-- Name: icecast_loggings icecast_loggings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_loggings
    ADD CONSTRAINT icecast_loggings_pkey PRIMARY KEY (id);


--
-- Name: icecast_master_server_relays icecast_master_server_relays_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_master_server_relays
    ADD CONSTRAINT icecast_master_server_relays_pkey PRIMARY KEY (id);


--
-- Name: icecast_mount_templates icecast_mount_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_mount_templates
    ADD CONSTRAINT icecast_mount_templates_pkey PRIMARY KEY (id);


--
-- Name: icecast_mounts icecast_mounts_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_mounts
    ADD CONSTRAINT icecast_mounts_name_key UNIQUE (name);


--
-- Name: icecast_mounts icecast_mounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_mounts
    ADD CONSTRAINT icecast_mounts_pkey PRIMARY KEY (id);


--
-- Name: icecast_paths icecast_paths_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_paths
    ADD CONSTRAINT icecast_paths_pkey PRIMARY KEY (id);


--
-- Name: icecast_relays icecast_relays_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_relays
    ADD CONSTRAINT icecast_relays_pkey PRIMARY KEY (id);


--
-- Name: icecast_securities icecast_securities_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_securities
    ADD CONSTRAINT icecast_securities_pkey PRIMARY KEY (id);


--
-- Name: icecast_server_groups icecast_server_groups_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_groups
    ADD CONSTRAINT icecast_server_groups_name_key UNIQUE (name);


--
-- Name: icecast_server_groups icecast_server_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_groups
    ADD CONSTRAINT icecast_server_groups_pkey PRIMARY KEY (id);


--
-- Name: icecast_server_mounts icecast_server_mounts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_mounts
    ADD CONSTRAINT icecast_server_mounts_pkey PRIMARY KEY (id);


--
-- Name: icecast_server_relays icecast_server_relays_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_relays
    ADD CONSTRAINT icecast_server_relays_pkey PRIMARY KEY (id);


--
-- Name: icecast_server_sockets icecast_server_sockets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_sockets
    ADD CONSTRAINT icecast_server_sockets_pkey PRIMARY KEY (id);


--
-- Name: icecast_servers icecast_servers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_pkey PRIMARY KEY (id);


--
-- Name: icecast_servers icecast_servers_server_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_server_id_key UNIQUE (server_id);


--
-- Name: icecast_source_changes icecast_source_changes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_source_changes
    ADD CONSTRAINT icecast_source_changes_pkey PRIMARY KEY (id);


--
-- Name: icecast_template_sockets icecast_template_sockets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_template_sockets
    ADD CONSTRAINT icecast_template_sockets_pkey PRIMARY KEY (id);


--
-- Name: icecast_templates icecast_templates_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_pkey PRIMARY KEY (id);


--
-- Name: icecast_user_authentications icecast_user_authentications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_user_authentications
    ADD CONSTRAINT icecast_user_authentications_pkey PRIMARY KEY (id);


--
-- Name: instruments instruments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.instruments
    ADD CONSTRAINT instruments_pkey PRIMARY KEY (id);


--
-- Name: invitations invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invitations
    ADD CONSTRAINT invitations_pkey PRIMARY KEY (id);


--
-- Name: invited_users invited_users_invitation_code_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invited_users
    ADD CONSTRAINT invited_users_invitation_code_key UNIQUE (invitation_code);


--
-- Name: invited_users invited_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invited_users
    ADD CONSTRAINT invited_users_pkey PRIMARY KEY (id);


--
-- Name: ip_blacklists ip_blacklists_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ip_blacklists
    ADD CONSTRAINT ip_blacklists_pkey PRIMARY KEY (id);


--
-- Name: ip_blacklists ip_blacklists_remote_ip_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ip_blacklists
    ADD CONSTRAINT ip_blacklists_remote_ip_key UNIQUE (remote_ip);


--
-- Name: ip_whitelists ip_whitelists_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ip_whitelists
    ADD CONSTRAINT ip_whitelists_pkey PRIMARY KEY (id);


--
-- Name: ip_whitelists ip_whitelists_remote_ip_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ip_whitelists
    ADD CONSTRAINT ip_whitelists_remote_ip_key UNIQUE (remote_ip);


--
-- Name: isp_score_batch isp_score_batch_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.isp_score_batch
    ADD CONSTRAINT isp_score_batch_pkey PRIMARY KEY (id);


--
-- Name: jam_track_files jam_track_files_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_files
    ADD CONSTRAINT jam_track_files_pkey PRIMARY KEY (id);


--
-- Name: jam_track_hfa_request_ids jam_track_hfa_request_ids_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_hfa_request_ids
    ADD CONSTRAINT jam_track_hfa_request_ids_pkey PRIMARY KEY (id);


--
-- Name: jam_track_hfa_requests jam_track_hfa_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_hfa_requests
    ADD CONSTRAINT jam_track_hfa_requests_pkey PRIMARY KEY (id);


--
-- Name: jam_track_licensors jam_track_licensors_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_licensors
    ADD CONSTRAINT jam_track_licensors_name_key UNIQUE (name);


--
-- Name: jam_track_licensors jam_track_licensors_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_licensors
    ADD CONSTRAINT jam_track_licensors_pkey PRIMARY KEY (id);


--
-- Name: jam_track_licensors jam_track_licensors_slug_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_licensors
    ADD CONSTRAINT jam_track_licensors_slug_key UNIQUE (slug);


--
-- Name: jam_track_mixdown_packages jam_track_mixdown_packages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_mixdown_packages
    ADD CONSTRAINT jam_track_mixdown_packages_pkey PRIMARY KEY (id);


--
-- Name: jam_track_mixdowns jam_track_mixdowns_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_mixdowns
    ADD CONSTRAINT jam_track_mixdowns_pkey PRIMARY KEY (id);


--
-- Name: jam_track_rights jam_track_rights_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_rights
    ADD CONSTRAINT jam_track_rights_pkey PRIMARY KEY (id);


--
-- Name: jam_track_sessions jam_track_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_sessions
    ADD CONSTRAINT jam_track_sessions_pkey PRIMARY KEY (id);


--
-- Name: jam_track_tap_ins jam_track_tap_ins_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_tap_ins
    ADD CONSTRAINT jam_track_tap_ins_pkey PRIMARY KEY (id);


--
-- Name: jam_track_tracks jam_track_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_tracks
    ADD CONSTRAINT jam_track_tracks_pkey PRIMARY KEY (id);


--
-- Name: jam_tracks jam_tracks_metalocation_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_tracks
    ADD CONSTRAINT jam_tracks_metalocation_key UNIQUE (metalocation);


--
-- Name: jam_tracks jam_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_tracks
    ADD CONSTRAINT jam_tracks_pkey PRIMARY KEY (id);


--
-- Name: jam_tracks jam_tracks_slug_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_tracks
    ADD CONSTRAINT jam_tracks_slug_key UNIQUE (slug);


--
-- Name: jamblaster_pairing_requests jamblaster_pairing_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblaster_pairing_requests
    ADD CONSTRAINT jamblaster_pairing_requests_pkey PRIMARY KEY (id);


--
-- Name: jamblasters jamblasters_client_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters
    ADD CONSTRAINT jamblasters_client_id_key UNIQUE (client_id);


--
-- Name: jamblasters jamblasters_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters
    ADD CONSTRAINT jamblasters_pkey PRIMARY KEY (id);


--
-- Name: jamblasters jamblasters_serial_no_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters
    ADD CONSTRAINT jamblasters_serial_no_key UNIQUE (serial_no);


--
-- Name: jamblasters_users jamblasters_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters_users
    ADD CONSTRAINT jamblasters_users_pkey PRIMARY KEY (id);


--
-- Name: jamcompany jamcompany_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamcompany
    ADD CONSTRAINT jamcompany_pkey PRIMARY KEY (coid);


--
-- Name: join_requests join_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.join_requests
    ADD CONSTRAINT join_requests_pkey PRIMARY KEY (id);


--
-- Name: json_stores json_stores_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.json_stores
    ADD CONSTRAINT json_stores_pkey PRIMARY KEY (id);


--
-- Name: languages languages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.languages
    ADD CONSTRAINT languages_pkey PRIMARY KEY (id);


--
-- Name: latency_testers latency_testers_client_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.latency_testers
    ADD CONSTRAINT latency_testers_client_id_key UNIQUE (client_id);


--
-- Name: latency_testers latency_testers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.latency_testers
    ADD CONSTRAINT latency_testers_pkey PRIMARY KEY (id);


--
-- Name: lesson_booking_slots lesson_booking_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_booking_slots
    ADD CONSTRAINT lesson_booking_slots_pkey PRIMARY KEY (id);


--
-- Name: lesson_bookings lesson_bookings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_pkey PRIMARY KEY (id);


--
-- Name: lesson_package_purchases lesson_package_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_purchases
    ADD CONSTRAINT lesson_package_purchases_pkey PRIMARY KEY (id);


--
-- Name: lesson_package_types lesson_package_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_types
    ADD CONSTRAINT lesson_package_types_pkey PRIMARY KEY (id);


--
-- Name: lesson_sessions lesson_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_pkey PRIMARY KEY (id);


--
-- Name: likes likes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.likes
    ADD CONSTRAINT likes_pkey PRIMARY KEY (id);


--
-- Name: likes likes_user_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.likes
    ADD CONSTRAINT likes_user_uniqkey UNIQUE (user_id, likable_id);


--
-- Name: live_streams live_streams_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.live_streams
    ADD CONSTRAINT live_streams_pkey PRIMARY KEY (id);


--
-- Name: live_streams live_streams_slug_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.live_streams
    ADD CONSTRAINT live_streams_slug_key UNIQUE (slug);


--
-- Name: machine_extras machine_extras_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.machine_extras
    ADD CONSTRAINT machine_extras_pkey PRIMARY KEY (id);


--
-- Name: machine_fingerprints machine_fingerprints_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.machine_fingerprints
    ADD CONSTRAINT machine_fingerprints_pkey PRIMARY KEY (id);


--
-- Name: max_mind_releases max_mind_releases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.max_mind_releases
    ADD CONSTRAINT max_mind_releases_pkey PRIMARY KEY (id);


--
-- Name: max_mind_releases max_mind_releases_released_at_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.max_mind_releases
    ADD CONSTRAINT max_mind_releases_released_at_key UNIQUE (released_at);


--
-- Name: mixes mixes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.mixes
    ADD CONSTRAINT mixes_pkey PRIMARY KEY (id);


--
-- Name: music_notations music_notations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_notations
    ADD CONSTRAINT music_notations_pkey PRIMARY KEY (id);


--
-- Name: music_session_perf_data music_session_perf_data_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_session_perf_data
    ADD CONSTRAINT music_session_perf_data_pkey PRIMARY KEY (id);


--
-- Name: music_sessions music_session_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_session_uniqkey UNIQUE (music_session_id);


--
-- Name: music_sessions_comments music_sessions_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_comments
    ADD CONSTRAINT music_sessions_comments_pkey PRIMARY KEY (id);


--
-- Name: music_sessions music_sessions_history_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_history_pkey PRIMARY KEY (id);


--
-- Name: music_sessions_likers music_sessions_likers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_likers
    ADD CONSTRAINT music_sessions_likers_pkey PRIMARY KEY (id);


--
-- Name: active_music_sessions music_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.active_music_sessions
    ADD CONSTRAINT music_sessions_pkey PRIMARY KEY (id);


--
-- Name: musicians_instruments musician_instrument_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.musicians_instruments
    ADD CONSTRAINT musician_instrument_uniqkey UNIQUE (player_id, instrument_id);


--
-- Name: claimed_recordings musician_recording_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.claimed_recordings
    ADD CONSTRAINT musician_recording_uniqkey UNIQUE (user_id, recording_id);


--
-- Name: musicians_instruments musicians_instruments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.musicians_instruments
    ADD CONSTRAINT musicians_instruments_pkey PRIMARY KEY (id);


--
-- Name: news news_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.news
    ADD CONSTRAINT news_pkey PRIMARY KEY (id);


--
-- Name: news news_position_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.news
    ADD CONSTRAINT news_position_key UNIQUE ("position");


--
-- Name: notifications notifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_pkey PRIMARY KEY (id);


--
-- Name: online_presences online_presences_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.online_presences
    ADD CONSTRAINT online_presences_pkey PRIMARY KEY (id);


--
-- Name: performance_samples performance_samples_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.performance_samples
    ADD CONSTRAINT performance_samples_pkey PRIMARY KEY (id);


--
-- Name: jam_tracks plan_code_unique; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_tracks
    ADD CONSTRAINT plan_code_unique UNIQUE (plan_code);


--
-- Name: playable_plays playable_plays_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.playable_plays
    ADD CONSTRAINT playable_plays_pkey PRIMARY KEY (id);


--
-- Name: posa_card_purchases posa_card_purchases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_card_purchases
    ADD CONSTRAINT posa_card_purchases_pkey PRIMARY KEY (id);


--
-- Name: posa_card_types posa_card_types_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_card_types
    ADD CONSTRAINT posa_card_types_pkey PRIMARY KEY (id);


--
-- Name: posa_cards posa_cards_code_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_cards
    ADD CONSTRAINT posa_cards_code_key UNIQUE (code);


--
-- Name: posa_cards posa_cards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_cards
    ADD CONSTRAINT posa_cards_pkey PRIMARY KEY (id);


--
-- Name: promotionals promotionals_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.promotionals
    ADD CONSTRAINT promotionals_pkey PRIMARY KEY (id);


--
-- Name: quick_mixes quick_mixes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.quick_mixes
    ADD CONSTRAINT quick_mixes_pkey PRIMARY KEY (id);


--
-- Name: recorded_backing_tracks recorded_backing_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_backing_tracks
    ADD CONSTRAINT recorded_backing_tracks_pkey PRIMARY KEY (id);


--
-- Name: recorded_jam_track_tracks recorded_jam_track_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_jam_track_tracks
    ADD CONSTRAINT recorded_jam_track_tracks_pkey PRIMARY KEY (id);


--
-- Name: recorded_videos recorded_videos_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_videos
    ADD CONSTRAINT recorded_videos_pkey PRIMARY KEY (id);


--
-- Name: recordings_likers recording_liker_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_likers
    ADD CONSTRAINT recording_liker_uniqkey UNIQUE (recording_id, liker_id);


--
-- Name: recordings_comments recordings_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_comments
    ADD CONSTRAINT recordings_comments_pkey PRIMARY KEY (id);


--
-- Name: recordings_downloads recordings_downloads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_downloads
    ADD CONSTRAINT recordings_downloads_pkey PRIMARY KEY (id);


--
-- Name: recordings_likers recordings_likers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_likers
    ADD CONSTRAINT recordings_likers_pkey PRIMARY KEY (id);


--
-- Name: recordings recordings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings
    ADD CONSTRAINT recordings_pkey PRIMARY KEY (id);


--
-- Name: recurly_transaction_web_hooks recurly_transaction_web_hooks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurly_transaction_web_hooks
    ADD CONSTRAINT recurly_transaction_web_hooks_pkey PRIMARY KEY (id);


--
-- Name: recurring_sessions recurring_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurring_sessions
    ADD CONSTRAINT recurring_sessions_pkey PRIMARY KEY (id);


--
-- Name: retailer_invitations retailer_invitations_invitation_code_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailer_invitations
    ADD CONSTRAINT retailer_invitations_invitation_code_key UNIQUE (invitation_code);


--
-- Name: retailer_invitations retailer_invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailer_invitations
    ADD CONSTRAINT retailer_invitations_pkey PRIMARY KEY (id);


--
-- Name: retailers retailers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailers
    ADD CONSTRAINT retailers_pkey PRIMARY KEY (id);


--
-- Name: retailers retailers_special_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailers
    ADD CONSTRAINT retailers_special_key UNIQUE (special);


--
-- Name: review_summaries review_summaries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.review_summaries
    ADD CONSTRAINT review_summaries_pkey PRIMARY KEY (id);


--
-- Name: reviews reviews_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_pkey PRIMARY KEY (id);


--
-- Name: rsvp_requests rsvp_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_requests
    ADD CONSTRAINT rsvp_requests_pkey PRIMARY KEY (id);


--
-- Name: rsvp_requests_rsvp_slots rsvp_requests_rsvp_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_requests_rsvp_slots
    ADD CONSTRAINT rsvp_requests_rsvp_slots_pkey PRIMARY KEY (id);


--
-- Name: rsvp_slots rsvp_slots_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_slots
    ADD CONSTRAINT rsvp_slots_pkey PRIMARY KEY (id);


--
-- Name: sale_line_items sale_line_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_pkey PRIMARY KEY (id);


--
-- Name: sales sales_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sales
    ADD CONSTRAINT sales_pkey PRIMARY KEY (id);


--
-- Name: sales sales_recurly_invoice_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sales
    ADD CONSTRAINT sales_recurly_invoice_id_key UNIQUE (recurly_invoice_id);


--
-- Name: recorded_tracks saved_tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_tracks
    ADD CONSTRAINT saved_tracks_pkey PRIMARY KEY (id);


--
-- Name: school_invitations school_invitations_invitation_code_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.school_invitations
    ADD CONSTRAINT school_invitations_invitation_code_key UNIQUE (invitation_code);


--
-- Name: school_invitations school_invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.school_invitations
    ADD CONSTRAINT school_invitations_pkey PRIMARY KEY (id);


--
-- Name: schools schools_name_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schools
    ADD CONSTRAINT schools_name_uniqkey UNIQUE (name);


--
-- Name: schools schools_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schools
    ADD CONSTRAINT schools_pkey PRIMARY KEY (id);


--
-- Name: schools schools_school_tag_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schools
    ADD CONSTRAINT schools_school_tag_key UNIQUE (school_tag);


--
-- Name: schools schools_special_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schools
    ADD CONSTRAINT schools_special_key UNIQUE (special);


--
-- Name: icecast_server_mounts server_mount_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_mounts
    ADD CONSTRAINT server_mount_uniqkey UNIQUE (icecast_mount_id, icecast_server_id);


--
-- Name: icecast_server_relays server_relay_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_relays
    ADD CONSTRAINT server_relay_uniqkey UNIQUE (icecast_relay_id, icecast_server_id);


--
-- Name: icecast_server_sockets server_socket_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_sockets
    ADD CONSTRAINT server_socket_uniqkey UNIQUE (icecast_listen_socket_id, icecast_server_id);


--
-- Name: session_info_comments session_info_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.session_info_comments
    ADD CONSTRAINT session_info_comments_pkey PRIMARY KEY (id);


--
-- Name: share_tokens share_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_tokens
    ADD CONSTRAINT share_tokens_pkey PRIMARY KEY (id);


--
-- Name: shopping_carts shopping_carts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.shopping_carts
    ADD CONSTRAINT shopping_carts_pkey PRIMARY KEY (id);


--
-- Name: signup_hints signup_hints_anonymous_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.signup_hints
    ADD CONSTRAINT signup_hints_anonymous_user_id_key UNIQUE (anonymous_user_id);


--
-- Name: signup_hints signup_hints_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.signup_hints
    ADD CONSTRAINT signup_hints_pkey PRIMARY KEY (id);


--
-- Name: subjects subjects_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.subjects
    ADD CONSTRAINT subjects_pkey PRIMARY KEY (id);


--
-- Name: teacher_distributions teacher_distributions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_pkey PRIMARY KEY (id);


--
-- Name: teacher_experiences teacher_experiences_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_experiences
    ADD CONSTRAINT teacher_experiences_pkey PRIMARY KEY (id);


--
-- Name: teacher_intents teacher_intents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_intents
    ADD CONSTRAINT teacher_intents_pkey PRIMARY KEY (id);


--
-- Name: teacher_payments teacher_payments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_payments
    ADD CONSTRAINT teacher_payments_pkey PRIMARY KEY (id);


--
-- Name: teachers teachers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers
    ADD CONSTRAINT teachers_pkey PRIMARY KEY (id);


--
-- Name: icecast_template_sockets template_socket_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_template_sockets
    ADD CONSTRAINT template_socket_uniqkey UNIQUE (icecast_listen_socket_id, icecast_template_id);


--
-- Name: test_drive_package_choice_teachers test_drive_package_choice_teachers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_choice_teachers
    ADD CONSTRAINT test_drive_package_choice_teachers_pkey PRIMARY KEY (id);


--
-- Name: test_drive_package_choices test_drive_package_choices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_choices
    ADD CONSTRAINT test_drive_package_choices_pkey PRIMARY KEY (id);


--
-- Name: test_drive_package_teachers test_drive_package_teachers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_teachers
    ADD CONSTRAINT test_drive_package_teachers_pkey PRIMARY KEY (id);


--
-- Name: test_drive_packages test_drive_packages_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_packages
    ADD CONSTRAINT test_drive_packages_name_key UNIQUE (name);


--
-- Name: test_drive_packages test_drive_packages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_packages
    ADD CONSTRAINT test_drive_packages_pkey PRIMARY KEY (id);


--
-- Name: text_messages text_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.text_messages
    ADD CONSTRAINT text_messages_pkey PRIMARY KEY (id);


--
-- Name: share_tokens token_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.share_tokens
    ADD CONSTRAINT token_uniqkey UNIQUE (token);


--
-- Name: tracks tracks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.tracks
    ADD CONSTRAINT tracks_pkey PRIMARY KEY (id);


--
-- Name: user_authorizations user_authorizations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_authorizations
    ADD CONSTRAINT user_authorizations_pkey PRIMARY KEY (id);


--
-- Name: user_authorizations user_authorizations_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_authorizations
    ADD CONSTRAINT user_authorizations_uniqkey UNIQUE (provider, uid);


--
-- Name: user_blacklists user_blacklists_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_blacklists
    ADD CONSTRAINT user_blacklists_pkey PRIMARY KEY (id);


--
-- Name: user_blacklists user_blacklists_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_blacklists
    ADD CONSTRAINT user_blacklists_user_id_key UNIQUE (user_id);


--
-- Name: user_events user_events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_events
    ADD CONSTRAINT user_events_pkey PRIMARY KEY (id);


--
-- Name: friendships user_friend_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friendships
    ADD CONSTRAINT user_friend_uniqkey UNIQUE (user_id, friend_id);


--
-- Name: join_requests user_music_session_uniqkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.join_requests
    ADD CONSTRAINT user_music_session_uniqkey UNIQUE (user_id, music_session_id);


--
-- Name: user_whitelists user_whitelists_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_whitelists
    ADD CONSTRAINT user_whitelists_pkey PRIMARY KEY (id);


--
-- Name: user_whitelists user_whitelists_user_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_whitelists
    ADD CONSTRAINT user_whitelists_user_id_key UNIQUE (user_id);


--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_email_key UNIQUE (email);


--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);


--
-- Name: users users_remember_token_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_remember_token_key UNIQUE (remember_token);


--
-- Name: users users_signup_token_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_signup_token_key UNIQUE (signup_token);


--
-- Name: users users_update_email_token_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_update_email_token_key UNIQUE (update_email_token);


--
-- Name: video_sources video_sources_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.video_sources
    ADD CONSTRAINT video_sources_pkey PRIMARY KEY (id);


--
-- Name: pg_migrate_unique_index; Type: INDEX; Schema: pgmigrate; Owner: -
--

CREATE INDEX pg_migrate_unique_index ON pgmigrate.pg_migrate USING btree (template_version, builder_version, migrator_version, database_version);


--
-- Name: affiliate_monthly_payments_affiliate_partner_id_year_month_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX affiliate_monthly_payments_affiliate_partner_id_year_month_idx ON public.affiliate_monthly_payments USING btree (affiliate_partner_id, year, month);


--
-- Name: affiliate_monthly_payments_year_month_affiliate_partner_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX affiliate_monthly_payments_year_month_affiliate_partner_id_idx ON public.affiliate_monthly_payments USING btree (year, month, affiliate_partner_id);


--
-- Name: affiliate_partners_legalese_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX affiliate_partners_legalese_idx ON public.affiliate_partners USING btree (legalese_id);


--
-- Name: affiliate_quarterly_payments_affiliate_partner_id_year_quar_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX affiliate_quarterly_payments_affiliate_partner_id_year_quar_idx ON public.affiliate_quarterly_payments USING btree (affiliate_partner_id, year, quarter);


--
-- Name: affiliate_quarterly_payments_year_quarter_affiliate_partner_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX affiliate_quarterly_payments_year_quarter_affiliate_partner_idx ON public.affiliate_quarterly_payments USING btree (year, quarter, affiliate_partner_id);


--
-- Name: affiliate_referral_visits_affiliate_partner_id_created_at_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX affiliate_referral_visits_affiliate_partner_id_created_at_idx ON public.affiliate_referral_visits USING btree (affiliate_partner_id, created_at);


--
-- Name: affiliate_traffic_totals_affiliate_partner_id_day_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX affiliate_traffic_totals_affiliate_partner_id_day_idx ON public.affiliate_traffic_totals USING btree (affiliate_partner_id, day);


--
-- Name: affiliate_traffic_totals_day_affiliate_partner_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX affiliate_traffic_totals_day_affiliate_partner_id_idx ON public.affiliate_traffic_totals USING btree (day, affiliate_partner_id);


--
-- Name: ams_is_platform_instructor_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX ams_is_platform_instructor_idx ON public.active_music_sessions USING btree ((1)) WHERE is_platform_instructor;


--
-- Name: band_id_2_for_feeds; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX band_id_2_for_feeds ON public.recordings USING btree (band_id);


--
-- Name: band_id_for_feeds; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX band_id_for_feeds ON public.music_sessions USING btree (band_id);


--
-- Name: bands_musicians_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX bands_musicians_user_id_idx ON public.bands_musicians USING btree (user_id);


--
-- Name: bands_name_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX bands_name_tsv_index ON public.bands USING gin (name_tsv);


--
-- Name: chat_messages_idx_channels; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX chat_messages_idx_channels ON public.chat_messages USING btree (channel);


--
-- Name: chat_messages_idx_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX chat_messages_idx_created_at ON public.chat_messages USING btree (created_at);


--
-- Name: chat_messages_idx_music_session_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX chat_messages_idx_music_session_id ON public.chat_messages USING btree (music_session_id);


--
-- Name: claimed_recordings_description_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX claimed_recordings_description_tsv_index ON public.claimed_recordings USING gin (description_tsv);


--
-- Name: claimed_recordings_name_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX claimed_recordings_name_tsv_index ON public.claimed_recordings USING gin (name_tsv);


--
-- Name: connections_locidispid_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX connections_locidispid_ndx ON public.connections USING btree (locidispid);


--
-- Name: crash_dumps_client_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX crash_dumps_client_id_idx ON public.crash_dumps USING btree (client_id);


--
-- Name: crash_dumps_timestamp_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX crash_dumps_timestamp_idx ON public.crash_dumps USING btree ("timestamp");


--
-- Name: crash_dumps_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX crash_dumps_user_id_idx ON public.crash_dumps USING btree (user_id);


--
-- Name: current_network_scores_a_b_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX current_network_scores_a_b_ndx ON public.current_network_scores USING btree (alocidispid, blocidispid);


--
-- Name: current_network_scores_b_a_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX current_network_scores_b_a_ndx ON public.current_network_scores USING btree (blocidispid, alocidispid);


--
-- Name: diagnostics_type_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX diagnostics_type_idx ON public.diagnostics USING btree (type);


--
-- Name: diagnostics_user_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX diagnostics_user_id ON public.diagnostics USING btree (user_id);


--
-- Name: email_batch_set_fkidx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX email_batch_set_fkidx ON public.email_batch_sets USING btree (email_batch_id);


--
-- Name: email_batch_sets_progress_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX email_batch_sets_progress_idx ON public.email_batch_sets USING btree (user_id, sub_type);


--
-- Name: email_error_address_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX email_error_address_idx ON public.email_errors USING btree (email_address);


--
-- Name: email_error_user_fkidx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX email_error_user_fkidx ON public.email_errors USING btree (user_id);


--
-- Name: feeds_is_platform_instructor_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX feeds_is_platform_instructor_idx ON public.feeds USING btree ((1)) WHERE is_platform_instructor;


--
-- Name: feeds_schood_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX feeds_schood_id_idx ON public.feeds USING btree (school_id);


--
-- Name: foreign_key1_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX foreign_key1_idx ON public.json_stores USING btree (foreign_key1_id);


--
-- Name: geoipisp_company_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX geoipisp_company_ndx ON public.geoipisp USING btree (company);


--
-- Name: gift_card_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX gift_card_user_id_idx ON public.gift_cards USING btree (user_id);


--
-- Name: idx_broadcast_broadcast_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_broadcast_broadcast_id ON public.broadcasts USING btree (broadcast_id);


--
-- Name: idx_broadcast_music_session_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_broadcast_music_session_id ON public.broadcasts USING btree (music_session_id);


--
-- Name: idx_broadcast_status; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_broadcast_status ON public.broadcasts USING btree (broadcast_status);


--
-- Name: idx_stream_status; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX idx_stream_status ON public.broadcasts USING btree (stream_status);


--
-- Name: index_active_admin_comments_on_author_type_and_author_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_active_admin_comments_on_author_type_and_author_id ON public.active_admin_comments USING btree (author_type, author_id);


--
-- Name: index_active_admin_comments_on_namespace; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_active_admin_comments_on_namespace ON public.active_admin_comments USING btree (namespace);


--
-- Name: index_admin_comments_on_resource_type_and_resource_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_admin_comments_on_resource_type_and_resource_id ON public.active_admin_comments USING btree (resource_type, resource_id);


--
-- Name: index_affiliate_traffic_totals_on_affiliate_partner_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_affiliate_traffic_totals_on_affiliate_partner_id ON public.affiliate_traffic_totals USING btree (affiliate_partner_id);


--
-- Name: index_affiliate_traffic_totals_on_day; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_affiliate_traffic_totals_on_day ON public.affiliate_traffic_totals USING btree (day);


--
-- Name: index_charges_on_billing_should_retry; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_charges_on_billing_should_retry ON public.charges USING btree (billing_should_retry);


--
-- Name: index_charges_on_type; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_charges_on_type ON public.charges USING btree (type);


--
-- Name: index_claimed_recordings_on_is_public; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_claimed_recordings_on_is_public ON public.claimed_recordings USING btree (is_public);


--
-- Name: index_claimed_recordings_on_recording_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_claimed_recordings_on_recording_id ON public.claimed_recordings USING btree (recording_id);


--
-- Name: index_completed_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_completed_at ON public.mixes USING btree (completed_at);


--
-- Name: index_download_trackers_on_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_download_trackers_on_created_at ON public.download_trackers USING btree (created_at, paid);


--
-- Name: index_download_trackers_on_fingerprint; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_download_trackers_on_fingerprint ON public.download_trackers USING btree (fingerprint);


--
-- Name: index_download_trackers_on_remote_ip; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_download_trackers_on_remote_ip ON public.download_trackers USING btree (remote_ip);


--
-- Name: index_download_trackers_on_user_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_download_trackers_on_user_id ON public.download_trackers USING btree (user_id);


--
-- Name: index_first_onboarding_paid_lesson_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_first_onboarding_paid_lesson_at ON public.users USING btree (first_onboarding_paid_lesson_at);


--
-- Name: index_group_date; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_group_date ON public.cohorts USING btree (group_start);


--
-- Name: index_invitations_on_music_session_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_invitations_on_music_session_id ON public.invitations USING btree (music_session_id);


--
-- Name: index_invitations_on_receiver_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_invitations_on_receiver_id ON public.invitations USING btree (receiver_id);


--
-- Name: index_lesson_sessions_on_charge_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_lesson_sessions_on_charge_id ON public.lesson_sessions USING btree (charge_id);


--
-- Name: index_lesson_sessions_on_sent_counter_reminder; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_lesson_sessions_on_sent_counter_reminder ON public.lesson_sessions USING btree (sent_counter_reminder);


--
-- Name: index_lesson_sessions_on_status; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_lesson_sessions_on_status ON public.lesson_sessions USING btree (status);


--
-- Name: index_music_sessions_on_canceled; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_canceled ON public.music_sessions USING btree (canceled);


--
-- Name: index_music_sessions_on_create_type; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_create_type ON public.music_sessions USING btree (create_type);


--
-- Name: index_music_sessions_on_lesson_session_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_lesson_session_id ON public.music_sessions USING btree (lesson_session_id);


--
-- Name: index_music_sessions_on_old; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_old ON public.music_sessions USING btree (old);


--
-- Name: index_music_sessions_on_scheduled_start; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_scheduled_start ON public.music_sessions USING btree (scheduled_start);


--
-- Name: index_music_sessions_on_session_removed_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_session_removed_at ON public.music_sessions USING btree (session_removed_at);


--
-- Name: index_music_sessions_on_started_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_music_sessions_on_started_at ON public.music_sessions USING btree (started_at);


--
-- Name: index_onboarding_onboarded_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_onboarding_onboarded_at ON public.users USING btree (onboarding_onboarded_at);


--
-- Name: index_onboarding_status; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_onboarding_status ON public.users USING btree (onboarding_status);


--
-- Name: index_posa_cards_lesson_package_type_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_posa_cards_lesson_package_type_id ON public.posa_cards USING btree (lesson_package_type_id);


--
-- Name: index_quick_mixes_on_cleaned; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_quick_mixes_on_cleaned ON public.quick_mixes USING btree (cleaned);


--
-- Name: index_quick_mixes_on_completed; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_quick_mixes_on_completed ON public.quick_mixes USING btree (completed);


--
-- Name: index_quick_mixes_on_recording_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_quick_mixes_on_recording_id ON public.quick_mixes USING btree (recording_id);


--
-- Name: index_recordings_on_all_discarded; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_recordings_on_all_discarded ON public.recordings USING btree (all_discarded);


--
-- Name: index_recordings_on_deleted; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_recordings_on_deleted ON public.recordings USING btree (deleted);


--
-- Name: index_recordings_on_first_quick_mix_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_recordings_on_first_quick_mix_id ON public.recordings USING btree (first_quick_mix_id);


--
-- Name: index_recordings_on_has_final_mix; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_recordings_on_has_final_mix ON public.recordings USING btree (has_final_mix);


--
-- Name: index_remind_take_lesson_times; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_remind_take_lesson_times ON public.users USING btree (remind_take_lesson_times);


--
-- Name: index_rsvp_requests_canceled; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_rsvp_requests_canceled ON public.rsvp_requests USING btree (canceled);


--
-- Name: index_rsvp_requests_rsvp_slots_on_chosen; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_rsvp_requests_rsvp_slots_on_chosen ON public.rsvp_requests_rsvp_slots USING btree (chosen);


--
-- Name: index_rsvp_requests_rsvp_slots_on_rsvp_request_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_rsvp_requests_rsvp_slots_on_rsvp_request_id ON public.rsvp_requests_rsvp_slots USING btree (rsvp_request_id);


--
-- Name: index_rsvp_requests_rsvp_slots_on_rsvp_slot_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_rsvp_requests_rsvp_slots_on_rsvp_slot_id ON public.rsvp_requests_rsvp_slots USING btree (rsvp_slot_id);


--
-- Name: index_rsvp_requests_user_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_rsvp_requests_user_id ON public.rsvp_requests USING btree (user_id);


--
-- Name: index_rsvp_slots_on_music_session_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_rsvp_slots_on_music_session_id ON public.rsvp_slots USING btree (music_session_id);


--
-- Name: index_sen_starting_notice; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sen_starting_notice ON public.lesson_sessions USING btree (sent_starting_notice);


--
-- Name: index_sent_admin_take_2nd_flesson_email_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sent_admin_take_2nd_flesson_email_at ON public.users USING btree (sent_admin_take_2nd_flesson_email_at);


--
-- Name: index_sent_admin_take_flesson_email_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sent_admin_take_flesson_email_at ON public.users USING btree (sent_admin_take_flesson_email_at);


--
-- Name: index_sent_admin_take_plesson_email_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sent_admin_take_plesson_email_at ON public.users USING btree (sent_admin_take_plesson_email_at);


--
-- Name: index_sent_early_starting_notice; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sent_early_starting_notice ON public.lesson_sessions USING btree (sent_early_starting_notice);


--
-- Name: index_sent_first_lesson_instr_email_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_sent_first_lesson_instr_email_at ON public.users USING btree (sent_first_lesson_instr_email_at);


--
-- Name: index_share_tokens_on_shareable_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_share_tokens_on_shareable_id ON public.share_tokens USING btree (shareable_id);


--
-- Name: index_started_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_started_at ON public.mixes USING btree (started_at);


--
-- Name: index_stuck_take_2nd_flesson; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_stuck_take_2nd_flesson ON public.users USING btree (stuck_take_2nd_flesson);


--
-- Name: index_stuck_take_flesson; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_stuck_take_flesson ON public.users USING btree (stuck_take_flesson);


--
-- Name: index_stuck_take_plesson; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_stuck_take_plesson ON public.users USING btree (stuck_take_plesson);


--
-- Name: index_users_on_affiliate_referral_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_affiliate_referral_id ON public.users USING btree (affiliate_referral_id);


--
-- Name: index_users_on_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_created_at ON public.users USING btree (created_at);


--
-- Name: jam_track_mixdown_packages_queued; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_track_mixdown_packages_queued ON public.jam_track_mixdown_packages USING btree (queued);


--
-- Name: jam_track_mixdown_packages_signing_queued; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_track_mixdown_packages_signing_queued ON public.jam_track_mixdown_packages USING btree (signing_queued_at);


--
-- Name: jam_track_mixdown_packages_updated; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_track_mixdown_packages_updated ON public.jam_track_mixdown_packages USING btree (updated_at);


--
-- Name: jam_track_rights_queued; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_track_rights_queued ON public.jam_track_rights USING btree (queued);


--
-- Name: jam_track_rights_signing_queued; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_track_rights_signing_queued ON public.jam_track_rights USING btree (signing_queued_at);


--
-- Name: jam_track_rights_updated; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_track_rights_updated ON public.jam_track_rights USING btree (updated_at);


--
-- Name: jam_tracks_artist_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_artist_tsv_index ON public.jam_tracks USING gin (artist_tsv);


--
-- Name: jam_tracks_language_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_language_idx ON public.jam_tracks USING btree (language);


--
-- Name: jam_tracks_name_key; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_name_key ON public.jam_tracks USING btree (name);


--
-- Name: jam_tracks_name_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_name_tsv_index ON public.jam_tracks USING gin (name_tsv);


--
-- Name: jam_tracks_original_artist_key; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_original_artist_key ON public.jam_tracks USING btree (original_artist);


--
-- Name: jam_tracks_rights_uniqkey; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_rights_uniqkey ON public.jam_track_rights USING btree (user_id, jam_track_id);


--
-- Name: jam_tracks_search_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_search_tsv_index ON public.jam_tracks USING gin (search_tsv);


--
-- Name: jam_tracks_status_key; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jam_tracks_status_key ON public.jam_tracks USING btree (status);


--
-- Name: jamcompany_company_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX jamcompany_company_ndx ON public.jamcompany USING btree (company);


--
-- Name: jamisp_coid_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX jamisp_coid_ndx ON public.jamisp USING btree (coid);


--
-- Name: json_stores_type; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX json_stores_type ON public.json_stores USING btree (type);


--
-- Name: machine_fingerprints_index1; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX machine_fingerprints_index1 ON public.machine_fingerprints USING btree (fingerprint, user_id, remote_ip, created_at);


--
-- Name: mixes_recording_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX mixes_recording_id_idx ON public.mixes USING btree (recording_id);


--
-- Name: mobile_recording_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX mobile_recording_id_idx ON public.mobile_recording_uploads USING btree (mobile_recording_id);


--
-- Name: msuh_client_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msuh_client_id ON public.music_sessions_user_history USING btree (client_id);


--
-- Name: msuh_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msuh_created_at ON public.music_sessions_user_history USING btree (created_at);


--
-- Name: msuh_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msuh_id_idx ON public.music_sessions_user_history USING btree (id);


--
-- Name: msuh_music_session_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msuh_music_session_idx ON public.music_sessions_user_history USING btree (music_session_id);


--
-- Name: msuh_record_id_for_feeds; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msuh_record_id_for_feeds ON public.music_sessions_user_history USING btree (music_session_id);


--
-- Name: msuh_user_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX msuh_user_id ON public.music_sessions_user_history USING btree (user_id);


--
-- Name: music_sessions_description_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX music_sessions_description_tsv_index ON public.music_sessions USING gin (description_tsv);


--
-- Name: music_sessions_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX music_sessions_user_id_idx ON public.music_sessions USING btree (user_id);


--
-- Name: posa_card_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX posa_card_user_id_idx ON public.posa_cards USING btree (user_id);


--
-- Name: promo_latest_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX promo_latest_idx ON public.promotionals USING btree (latest_id, latest_type);


--
-- Name: quick_mixes_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX quick_mixes_user_id_idx ON public.quick_mixes USING btree (user_id);


--
-- Name: recorded_backing_tracks_recording_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recorded_backing_tracks_recording_id_idx ON public.recorded_backing_tracks USING btree (recording_id);


--
-- Name: recorded_backing_tracks_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recorded_backing_tracks_user_id_idx ON public.recorded_backing_tracks USING btree (user_id);


--
-- Name: recorded_tracks_recording_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recorded_tracks_recording_id_idx ON public.recorded_tracks USING btree (recording_id);


--
-- Name: recorded_tracks_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recorded_tracks_user_id_idx ON public.recorded_tracks USING btree (user_id);


--
-- Name: recorded_videos_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recorded_videos_user_id_idx ON public.recorded_videos USING btree (user_id);


--
-- Name: recurly_transaction_web_hooks_invoice_id_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recurly_transaction_web_hooks_invoice_id_ndx ON public.recurly_transaction_web_hooks USING btree (invoice_id);


--
-- Name: recurly_transaction_web_hooks_subscription_id_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX recurly_transaction_web_hooks_subscription_id_ndx ON public.recurly_transaction_web_hooks USING btree (subscription_id);


--
-- Name: regions_countrycode_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX regions_countrycode_ndx ON public.regions USING btree (countrycode);


--
-- Name: regions_countrycode_region_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX regions_countrycode_region_ndx ON public.regions USING btree (countrycode, region);


--
-- Name: remember_token_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX remember_token_idx ON public.users USING btree (remember_token);


--
-- Name: rsvp_request_music_session_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX rsvp_request_music_session_id ON public.rsvp_requests USING btree (music_session_id);


--
-- Name: sale_line_items_recurly_subscription_uuid_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX sale_line_items_recurly_subscription_uuid_ndx ON public.sale_line_items USING btree (recurly_subscription_uuid);


--
-- Name: scores_alocidispid_blocidispid_score_dt_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX scores_alocidispid_blocidispid_score_dt_ndx ON public.scores USING btree (alocidispid, blocidispid, score_dt);


--
-- Name: scores_blocidispid_alocidispid_score_dt_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX scores_blocidispid_alocidispid_score_dt_ndx ON public.scores USING btree (blocidispid, alocidispid, score_dt);


--
-- Name: sms_is_platform_instructor_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX sms_is_platform_instructor_idx ON public.music_sessions USING btree ((1)) WHERE is_platform_instructor;


--
-- Name: subscription_sync_code_user_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX subscription_sync_code_user_index ON public.users USING btree (subscription_sync_code);


--
-- Name: teacher_intents_intent_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX teacher_intents_intent_idx ON public.teacher_intents USING btree (teacher_id, intent);


--
-- Name: trgm_idx_users_email; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX trgm_idx_users_email ON public.users USING gin (email public.gin_trgm_ops);


--
-- Name: user_authorizations_user_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX user_authorizations_user_id_idx ON public.user_authorizations USING btree (user_id);


--
-- Name: user_broadcast_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX user_broadcast_idx ON public.broadcast_notification_views USING btree (user_id, broadcast_notification_id);


--
-- Name: user_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX user_idx ON public.json_stores USING btree (user_id);


--
-- Name: users_is_a_student_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_is_a_student_idx ON public.users USING btree ((1)) WHERE is_a_student;


--
-- Name: users_is_a_teacher_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_is_a_teacher_idx ON public.users USING btree ((1)) WHERE is_a_teacher;


--
-- Name: users_is_platform_instructor_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_is_platform_instructor_idx ON public.users USING btree ((1)) WHERE is_platform_instructor;


--
-- Name: users_last_jam_locidispid_ndx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_last_jam_locidispid_ndx ON public.users USING btree (last_jam_locidispid);


--
-- Name: users_musician_email_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_musician_email_idx ON public.users USING btree (subscribe_email, musician);


--
-- Name: users_name_tsv_index; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_name_tsv_index ON public.users USING gin (name_tsv);


--
-- Name: users_schood_id_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX users_schood_id_idx ON public.users USING btree (school_id);


--
-- Name: connections connection_up_down; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER connection_up_down AFTER INSERT OR DELETE ON public.connections FOR EACH ROW EXECUTE PROCEDURE public.manage_user_online('user_id');


--
-- Name: users phantom_update; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER phantom_update BEFORE INSERT OR UPDATE ON public.users FOR EACH ROW EXECUTE PROCEDURE public.phantom_check('id');


--
-- Name: bands tsvectorupdate; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON public.bands FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('name_tsv', 'public.jamenglish', 'name');


--
-- Name: jam_tracks tsvectorupdate; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON public.jam_tracks FOR EACH ROW EXECUTE PROCEDURE public.jam_tracks_update_tsv();


--
-- Name: music_sessions tsvectorupdate; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON public.music_sessions FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('description_tsv', 'public.jamenglish', 'description', 'name', 'genre_id');


--
-- Name: users tsvectorupdate; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON public.users FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('name_tsv', 'public.jamenglish', 'first_name', 'last_name');


--
-- Name: claimed_recordings tsvectorupdate_description; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER tsvectorupdate_description BEFORE INSERT OR UPDATE ON public.claimed_recordings FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('description_tsv', 'public.jamenglish', 'description');


--
-- Name: claimed_recordings tsvectorupdate_name; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER tsvectorupdate_name BEFORE INSERT OR UPDATE ON public.claimed_recordings FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('name_tsv', 'public.jamenglish', 'name');


--
-- Name: pg_migrations pg_migrations_pg_migrate_id_fkey; Type: FK CONSTRAINT; Schema: pgmigrate; Owner: -
--

ALTER TABLE ONLY pgmigrate.pg_migrations
    ADD CONSTRAINT pg_migrations_pg_migrate_id_fkey FOREIGN KEY (pg_migrate_id) REFERENCES pgmigrate.pg_migrate(id);


--
-- Name: active_music_sessions active_music_sessions_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.active_music_sessions
    ADD CONSTRAINT active_music_sessions_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: affiliate_distributions affiliate_distributions_affiliate_referral_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_distributions
    ADD CONSTRAINT affiliate_distributions_affiliate_referral_id_fkey FOREIGN KEY (affiliate_referral_id) REFERENCES public.affiliate_partners(id);


--
-- Name: affiliate_distributions affiliate_distributions_sale_line_item_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_distributions
    ADD CONSTRAINT affiliate_distributions_sale_line_item_id_fkey FOREIGN KEY (sale_line_item_id) REFERENCES public.sale_line_items(id);


--
-- Name: affiliate_monthly_payments affiliate_monthly_payments_affiliate_partner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_monthly_payments
    ADD CONSTRAINT affiliate_monthly_payments_affiliate_partner_id_fkey FOREIGN KEY (affiliate_partner_id) REFERENCES public.affiliate_partners(id);


--
-- Name: affiliate_partners affiliate_partners_partner_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_partners
    ADD CONSTRAINT affiliate_partners_partner_user_id_fkey FOREIGN KEY (partner_user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: affiliate_quarterly_payments affiliate_quarterly_payments_affiliate_partner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_quarterly_payments
    ADD CONSTRAINT affiliate_quarterly_payments_affiliate_partner_id_fkey FOREIGN KEY (affiliate_partner_id) REFERENCES public.affiliate_partners(id);


--
-- Name: affiliate_traffic_totals affiliate_traffic_totals_affiliate_partner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.affiliate_traffic_totals
    ADD CONSTRAINT affiliate_traffic_totals_affiliate_partner_id_fkey FOREIGN KEY (affiliate_partner_id) REFERENCES public.affiliate_partners(id);


--
-- Name: backing_tracks backing_tracks_connection_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.backing_tracks
    ADD CONSTRAINT backing_tracks_connection_id_fkey FOREIGN KEY (connection_id) REFERENCES public.connections(id) ON DELETE CASCADE;


--
-- Name: band_invitations band_invitations_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.band_invitations
    ADD CONSTRAINT band_invitations_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE CASCADE;


--
-- Name: band_invitations band_invitations_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.band_invitations
    ADD CONSTRAINT band_invitations_creator_id_fkey FOREIGN KEY (creator_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: band_invitations band_invitations_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.band_invitations
    ADD CONSTRAINT band_invitations_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: genre_players bands_genres_genre_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genre_players
    ADD CONSTRAINT bands_genres_genre_id_fkey FOREIGN KEY (genre_id) REFERENCES public.genres(id) ON DELETE CASCADE;


--
-- Name: bands_musicians bands_musicians_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bands_musicians
    ADD CONSTRAINT bands_musicians_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE CASCADE;


--
-- Name: bands_musicians bands_musicians_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.bands_musicians
    ADD CONSTRAINT bands_musicians_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: broadcast_notification_views broadcast_notification_views_broadcast_notification_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcast_notification_views
    ADD CONSTRAINT broadcast_notification_views_broadcast_notification_id_fkey FOREIGN KEY (broadcast_notification_id) REFERENCES public.broadcast_notifications(id) ON DELETE CASCADE;


--
-- Name: broadcast_notification_views broadcast_notification_views_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcast_notification_views
    ADD CONSTRAINT broadcast_notification_views_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: broadcasts broadcasts_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcasts
    ADD CONSTRAINT broadcasts_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: broadcasts broadcasts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.broadcasts
    ADD CONSTRAINT broadcasts_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: calendars calendars_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.calendars
    ADD CONSTRAINT calendars_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: charges charges_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.charges
    ADD CONSTRAINT charges_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: chat_messages chat_messages_claimed_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_claimed_recording_id_fkey FOREIGN KEY (claimed_recording_id) REFERENCES public.claimed_recordings(id);


--
-- Name: chat_messages chat_messages_lesson_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_lesson_session_id_fkey FOREIGN KEY (lesson_session_id) REFERENCES public.lesson_sessions(id) ON DELETE CASCADE;


--
-- Name: chat_messages chat_messages_music_notation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_music_notation_id_fkey FOREIGN KEY (music_notation_id) REFERENCES public.music_notations(id);


--
-- Name: chat_messages chat_messages_target_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_target_user_id_fkey FOREIGN KEY (lesson_session_id) REFERENCES public.lesson_sessions(id) ON DELETE SET NULL;


--
-- Name: chat_messages chat_messages_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.chat_messages
    ADD CONSTRAINT chat_messages_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: claimed_recordings claimed_recordings_genre_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.claimed_recordings
    ADD CONSTRAINT claimed_recordings_genre_id_fkey FOREIGN KEY (genre_id) REFERENCES public.genres(id);


--
-- Name: client_live_streams client_live_streams_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.client_live_streams
    ADD CONSTRAINT client_live_streams_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: client_live_streams client_live_streams_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.client_live_streams
    ADD CONSTRAINT client_live_streams_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: connections connections_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.connections
    ADD CONSTRAINT connections_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.active_music_sessions(id) ON DELETE SET NULL;


--
-- Name: tracks connections_tracks_connection_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.tracks
    ADD CONSTRAINT connections_tracks_connection_id_fkey FOREIGN KEY (connection_id) REFERENCES public.connections(id) ON DELETE CASCADE;


--
-- Name: crash_dumps crash_dumps_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.crash_dumps
    ADD CONSTRAINT crash_dumps_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: diagnostics diagnostics_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.diagnostics
    ADD CONSTRAINT diagnostics_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: download_trackers download_trackers_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.download_trackers
    ADD CONSTRAINT download_trackers_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: download_trackers download_trackers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.download_trackers
    ADD CONSTRAINT download_trackers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: email_batch_sets email_batch_sets_email_batch_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_batch_sets
    ADD CONSTRAINT email_batch_sets_email_batch_id_fkey FOREIGN KEY (email_batch_id) REFERENCES public.email_batches(id) ON DELETE CASCADE;


--
-- Name: email_errors email_errors_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.email_errors
    ADD CONSTRAINT email_errors_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: event_brite_orders event_brite_orders_event_brite_order_upload_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_brite_orders
    ADD CONSTRAINT event_brite_orders_event_brite_order_upload_id_fkey FOREIGN KEY (event_brite_order_upload_id) REFERENCES public.event_brite_order_uploads(id) ON DELETE CASCADE;


--
-- Name: event_brite_orders event_brite_orders_live_stream_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_brite_orders
    ADD CONSTRAINT event_brite_orders_live_stream_id_fkey FOREIGN KEY (live_stream_id) REFERENCES public.live_streams(id) ON DELETE CASCADE;


--
-- Name: event_sessions event_sessions_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_sessions
    ADD CONSTRAINT event_sessions_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE SET NULL;


--
-- Name: event_sessions event_sessions_event_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_sessions
    ADD CONSTRAINT event_sessions_event_id_fkey FOREIGN KEY (event_id) REFERENCES public.events(id) ON DELETE CASCADE;


--
-- Name: event_sessions event_sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.event_sessions
    ADD CONSTRAINT event_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: fan_invitations fan_invitations_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fan_invitations
    ADD CONSTRAINT fan_invitations_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: feeds feeds_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: feeds feeds_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.feeds
    ADD CONSTRAINT feeds_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: follows follows_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.follows
    ADD CONSTRAINT follows_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: fraud_alerts fraud_alerts_machine_fingerprint_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fraud_alerts
    ADD CONSTRAINT fraud_alerts_machine_fingerprint_id_fkey FOREIGN KEY (machine_fingerprint_id) REFERENCES public.machine_fingerprints(id) ON DELETE CASCADE;


--
-- Name: fraud_alerts fraud_alerts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.fraud_alerts
    ADD CONSTRAINT fraud_alerts_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: friend_requests friend_requests_friend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friend_requests
    ADD CONSTRAINT friend_requests_friend_id_fkey FOREIGN KEY (friend_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: friend_requests friend_requests_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friend_requests
    ADD CONSTRAINT friend_requests_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: friendships friendships_friend_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friendships
    ADD CONSTRAINT friendships_friend_id_fkey FOREIGN KEY (friend_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: friendships friendships_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.friendships
    ADD CONSTRAINT friendships_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: genres_jam_tracks genres_jam_tracks_genre_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genres_jam_tracks
    ADD CONSTRAINT genres_jam_tracks_genre_id_fkey FOREIGN KEY (genre_id) REFERENCES public.genres(id) ON DELETE CASCADE;


--
-- Name: genres_jam_tracks genres_jam_tracks_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genres_jam_tracks
    ADD CONSTRAINT genres_jam_tracks_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: genres_music_sessions genres_music_sessions_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.genres_music_sessions
    ADD CONSTRAINT genres_music_sessions_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.active_music_sessions(id) ON DELETE CASCADE;


--
-- Name: gift_card_purchases gift_card_purchases_gift_card_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_card_purchases
    ADD CONSTRAINT gift_card_purchases_gift_card_type_id_fkey FOREIGN KEY (gift_card_type_id) REFERENCES public.gift_card_types(id) ON DELETE SET NULL;


--
-- Name: gift_card_purchases gift_card_purchases_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_card_purchases
    ADD CONSTRAINT gift_card_purchases_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: gift_cards gift_cards_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.gift_cards
    ADD CONSTRAINT gift_cards_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: icecast_mounts icecast_mounts_icecast_mount_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_mounts
    ADD CONSTRAINT icecast_mounts_icecast_mount_template_id_fkey FOREIGN KEY (icecast_mount_template_id) REFERENCES public.icecast_mount_templates(id) ON DELETE SET NULL;


--
-- Name: icecast_mounts icecast_mounts_icecast_server_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_mounts
    ADD CONSTRAINT icecast_mounts_icecast_server_id_fkey FOREIGN KEY (icecast_server_id) REFERENCES public.icecast_servers(id) ON DELETE SET NULL;


--
-- Name: icecast_mounts icecast_mounts_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_mounts
    ADD CONSTRAINT icecast_mounts_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.active_music_sessions(id) ON DELETE CASCADE;


--
-- Name: icecast_server_mounts icecast_server_mounts_icecast_server_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_mounts
    ADD CONSTRAINT icecast_server_mounts_icecast_server_id_fkey FOREIGN KEY (icecast_server_id) REFERENCES public.icecast_servers(id) ON DELETE CASCADE;


--
-- Name: icecast_server_relays icecast_server_relays_icecast_relay_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_relays
    ADD CONSTRAINT icecast_server_relays_icecast_relay_id_fkey FOREIGN KEY (icecast_relay_id) REFERENCES public.icecast_relays(id) ON DELETE CASCADE;


--
-- Name: icecast_server_relays icecast_server_relays_icecast_server_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_relays
    ADD CONSTRAINT icecast_server_relays_icecast_server_id_fkey FOREIGN KEY (icecast_server_id) REFERENCES public.icecast_servers(id) ON DELETE CASCADE;


--
-- Name: icecast_server_sockets icecast_server_sockets_icecast_listen_socket_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_sockets
    ADD CONSTRAINT icecast_server_sockets_icecast_listen_socket_id_fkey FOREIGN KEY (icecast_listen_socket_id) REFERENCES public.icecast_listen_sockets(id) ON DELETE CASCADE;


--
-- Name: icecast_server_sockets icecast_server_sockets_icecast_server_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_server_sockets
    ADD CONSTRAINT icecast_server_sockets_icecast_server_id_fkey FOREIGN KEY (icecast_server_id) REFERENCES public.icecast_servers(id) ON DELETE CASCADE;


--
-- Name: icecast_servers icecast_servers_admin_auth_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_admin_auth_id_fkey FOREIGN KEY (admin_auth_id) REFERENCES public.icecast_admin_authentications(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_directory_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_directory_id_fkey FOREIGN KEY (directory_id) REFERENCES public.icecast_directories(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_icecast_server_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_icecast_server_group_id_fkey FOREIGN KEY (icecast_server_group_id) REFERENCES public.icecast_server_groups(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_limit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_limit_id_fkey FOREIGN KEY (limit_id) REFERENCES public.icecast_limits(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_logging_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_logging_id_fkey FOREIGN KEY (logging_id) REFERENCES public.icecast_loggings(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_master_relay_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_master_relay_id_fkey FOREIGN KEY (master_relay_id) REFERENCES public.icecast_master_server_relays(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_mount_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_mount_template_id_fkey FOREIGN KEY (mount_template_id) REFERENCES public.icecast_mount_templates(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_path_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_path_id_fkey FOREIGN KEY (path_id) REFERENCES public.icecast_paths(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_security_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_security_id_fkey FOREIGN KEY (security_id) REFERENCES public.icecast_securities(id) ON DELETE SET NULL;


--
-- Name: icecast_servers icecast_servers_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_servers
    ADD CONSTRAINT icecast_servers_template_id_fkey FOREIGN KEY (template_id) REFERENCES public.icecast_templates(id) ON DELETE SET NULL;


--
-- Name: icecast_source_changes icecast_source_changes_icecast_mount_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_source_changes
    ADD CONSTRAINT icecast_source_changes_icecast_mount_id_fkey FOREIGN KEY (icecast_mount_id) REFERENCES public.icecast_mounts(id) ON DELETE CASCADE;


--
-- Name: icecast_template_sockets icecast_template_sockets_icecast_listen_socket_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_template_sockets
    ADD CONSTRAINT icecast_template_sockets_icecast_listen_socket_id_fkey FOREIGN KEY (icecast_listen_socket_id) REFERENCES public.icecast_listen_sockets(id) ON DELETE CASCADE;


--
-- Name: icecast_template_sockets icecast_template_sockets_icecast_template_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_template_sockets
    ADD CONSTRAINT icecast_template_sockets_icecast_template_id_fkey FOREIGN KEY (icecast_template_id) REFERENCES public.icecast_templates(id) ON DELETE CASCADE;


--
-- Name: icecast_templates icecast_templates_admin_auth_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_admin_auth_id_fkey FOREIGN KEY (admin_auth_id) REFERENCES public.icecast_admin_authentications(id) ON DELETE SET NULL;


--
-- Name: icecast_templates icecast_templates_directory_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_directory_id_fkey FOREIGN KEY (directory_id) REFERENCES public.icecast_directories(id) ON DELETE SET NULL;


--
-- Name: icecast_templates icecast_templates_limit_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_limit_id_fkey FOREIGN KEY (limit_id) REFERENCES public.icecast_limits(id) ON DELETE SET NULL;


--
-- Name: icecast_templates icecast_templates_logging_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_logging_id_fkey FOREIGN KEY (logging_id) REFERENCES public.icecast_loggings(id) ON DELETE SET NULL;


--
-- Name: icecast_templates icecast_templates_master_relay_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_master_relay_id_fkey FOREIGN KEY (master_relay_id) REFERENCES public.icecast_master_server_relays(id) ON DELETE SET NULL;


--
-- Name: icecast_templates icecast_templates_path_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_path_id_fkey FOREIGN KEY (path_id) REFERENCES public.icecast_paths(id) ON DELETE SET NULL;


--
-- Name: icecast_templates icecast_templates_security_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.icecast_templates
    ADD CONSTRAINT icecast_templates_security_id_fkey FOREIGN KEY (security_id) REFERENCES public.icecast_securities(id) ON DELETE SET NULL;


--
-- Name: invitations invitations_join_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invitations
    ADD CONSTRAINT invitations_join_request_id_fkey FOREIGN KEY (join_request_id) REFERENCES public.join_requests(id) ON DELETE CASCADE;


--
-- Name: invitations invitations_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invitations
    ADD CONSTRAINT invitations_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: invited_users invited_users_receiver_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invited_users
    ADD CONSTRAINT invited_users_receiver_id_fkey FOREIGN KEY (receiver_id) REFERENCES public.users(id);


--
-- Name: invited_users invited_users_sender_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.invited_users
    ADD CONSTRAINT invited_users_sender_id_fkey FOREIGN KEY (sender_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: jam_track_files jam_track_files_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_files
    ADD CONSTRAINT jam_track_files_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: jam_track_hfa_request_ids jam_track_hfa_request_ids_jam_track_hfa_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_hfa_request_ids
    ADD CONSTRAINT jam_track_hfa_request_ids_jam_track_hfa_request_id_fkey FOREIGN KEY (jam_track_hfa_request_id) REFERENCES public.jam_track_hfa_requests(id) ON DELETE SET NULL;


--
-- Name: jam_track_hfa_request_ids jam_track_hfa_request_ids_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_hfa_request_ids
    ADD CONSTRAINT jam_track_hfa_request_ids_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE SET NULL;


--
-- Name: jam_track_mixdown_packages jam_track_mixdown_packages_jam_track_mixdown_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_mixdown_packages
    ADD CONSTRAINT jam_track_mixdown_packages_jam_track_mixdown_id_fkey FOREIGN KEY (jam_track_mixdown_id) REFERENCES public.jam_track_mixdowns(id) ON DELETE CASCADE;


--
-- Name: jam_track_mixdowns jam_track_mixdowns_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_mixdowns
    ADD CONSTRAINT jam_track_mixdowns_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: jam_track_mixdowns jam_track_mixdowns_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_mixdowns
    ADD CONSTRAINT jam_track_mixdowns_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: jam_track_rights jam_track_rights_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_rights
    ADD CONSTRAINT jam_track_rights_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id);


--
-- Name: jam_track_rights jam_track_rights_last_mixdown_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_rights
    ADD CONSTRAINT jam_track_rights_last_mixdown_id_fkey FOREIGN KEY (last_mixdown_id) REFERENCES public.jam_track_mixdowns(id) ON DELETE SET NULL;


--
-- Name: jam_track_rights jam_track_rights_last_stem_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_rights
    ADD CONSTRAINT jam_track_rights_last_stem_id_fkey FOREIGN KEY (last_stem_id) REFERENCES public.jam_track_tracks(id) ON DELETE SET NULL;


--
-- Name: jam_track_rights jam_track_rights_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_rights
    ADD CONSTRAINT jam_track_rights_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: jam_track_sessions jam_track_sessions_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_sessions
    ADD CONSTRAINT jam_track_sessions_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: jam_track_sessions jam_track_sessions_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_sessions
    ADD CONSTRAINT jam_track_sessions_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE SET NULL;


--
-- Name: jam_track_sessions jam_track_sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_sessions
    ADD CONSTRAINT jam_track_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: jam_track_tap_ins jam_track_tap_ins_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_tap_ins
    ADD CONSTRAINT jam_track_tap_ins_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: jam_track_tracks jam_track_tracks_instrument_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_tracks
    ADD CONSTRAINT jam_track_tracks_instrument_id_fkey FOREIGN KEY (instrument_id) REFERENCES public.instruments(id) ON DELETE SET NULL;


--
-- Name: jam_track_tracks jam_track_tracks_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_track_tracks
    ADD CONSTRAINT jam_track_tracks_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id) ON DELETE CASCADE;


--
-- Name: jam_tracks jam_tracks_licensor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jam_tracks
    ADD CONSTRAINT jam_tracks_licensor_id_fkey FOREIGN KEY (licensor_id) REFERENCES public.jam_track_licensors(id) ON DELETE SET NULL;


--
-- Name: jamblaster_pairing_requests jamblaster_pairing_requests_jamblaster_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblaster_pairing_requests
    ADD CONSTRAINT jamblaster_pairing_requests_jamblaster_id_fkey FOREIGN KEY (jamblaster_id) REFERENCES public.jamblasters(id) ON DELETE CASCADE;


--
-- Name: jamblaster_pairing_requests jamblaster_pairing_requests_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblaster_pairing_requests
    ADD CONSTRAINT jamblaster_pairing_requests_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: jamblasters jamblasters_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters
    ADD CONSTRAINT jamblasters_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: jamblasters_users jamblasters_users_jamblaster_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters_users
    ADD CONSTRAINT jamblasters_users_jamblaster_id_fkey FOREIGN KEY (jamblaster_id) REFERENCES public.jamblasters(id) ON DELETE CASCADE;


--
-- Name: jamblasters_users jamblasters_users_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.jamblasters_users
    ADD CONSTRAINT jamblasters_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: join_requests join_requests_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.join_requests
    ADD CONSTRAINT join_requests_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: json_stores json_stores_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.json_stores
    ADD CONSTRAINT json_stores_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: lesson_booking_slots lesson_booking_slots_lesson_booking_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_booking_slots
    ADD CONSTRAINT lesson_booking_slots_lesson_booking_id_fkey FOREIGN KEY (lesson_booking_id) REFERENCES public.lesson_bookings(id) ON DELETE SET NULL;


--
-- Name: lesson_booking_slots lesson_booking_slots_lesson_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_booking_slots
    ADD CONSTRAINT lesson_booking_slots_lesson_session_id_fkey FOREIGN KEY (lesson_session_id) REFERENCES public.lesson_sessions(id);


--
-- Name: lesson_booking_slots lesson_booking_slots_proposer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_booking_slots
    ADD CONSTRAINT lesson_booking_slots_proposer_id_fkey FOREIGN KEY (proposer_id) REFERENCES public.users(id);


--
-- Name: lesson_bookings lesson_bookings_accepter_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_accepter_id_fkey FOREIGN KEY (accepter_id) REFERENCES public.users(id);


--
-- Name: lesson_bookings lesson_bookings_canceler_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_canceler_id_fkey FOREIGN KEY (canceler_id) REFERENCES public.users(id);


--
-- Name: lesson_bookings lesson_bookings_counter_slot_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_counter_slot_id_fkey FOREIGN KEY (counter_slot_id) REFERENCES public.lesson_booking_slots(id) ON DELETE CASCADE;


--
-- Name: lesson_bookings lesson_bookings_counterer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_counterer_id_fkey FOREIGN KEY (counterer_id) REFERENCES public.users(id);


--
-- Name: lesson_bookings lesson_bookings_default_slot_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_default_slot_id_fkey FOREIGN KEY (default_slot_id) REFERENCES public.lesson_booking_slots(id) ON DELETE CASCADE;


--
-- Name: lesson_bookings lesson_bookings_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: lesson_bookings lesson_bookings_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: lesson_bookings lesson_bookings_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.users(id);


--
-- Name: lesson_bookings lesson_bookings_test_drive_package_choice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_test_drive_package_choice_id_fkey FOREIGN KEY (test_drive_package_choice_id) REFERENCES public.test_drive_package_choices(id);


--
-- Name: lesson_bookings lesson_bookings_test_drive_package_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_test_drive_package_id_fkey FOREIGN KEY (test_drive_package_id) REFERENCES public.test_drive_packages(id);


--
-- Name: lesson_bookings lesson_bookings_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_bookings
    ADD CONSTRAINT lesson_bookings_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: lesson_package_purchases lesson_package_purchases_charge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_purchases
    ADD CONSTRAINT lesson_package_purchases_charge_id_fkey FOREIGN KEY (charge_id) REFERENCES public.charges(id);


--
-- Name: lesson_package_purchases lesson_package_purchases_lesson_booking_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_purchases
    ADD CONSTRAINT lesson_package_purchases_lesson_booking_id_fkey FOREIGN KEY (lesson_booking_id) REFERENCES public.lesson_bookings(id) ON DELETE SET NULL;


--
-- Name: lesson_package_purchases lesson_package_purchases_lesson_package_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_purchases
    ADD CONSTRAINT lesson_package_purchases_lesson_package_type_id_fkey FOREIGN KEY (lesson_package_type_id) REFERENCES public.lesson_package_types(id);


--
-- Name: lesson_package_purchases lesson_package_purchases_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_purchases
    ADD CONSTRAINT lesson_package_purchases_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.users(id);


--
-- Name: lesson_package_purchases lesson_package_purchases_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_package_purchases
    ADD CONSTRAINT lesson_package_purchases_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: lesson_sessions lesson_sessions_canceler_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_canceler_id_fkey FOREIGN KEY (canceler_id) REFERENCES public.users(id);


--
-- Name: lesson_sessions lesson_sessions_charge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_charge_id_fkey FOREIGN KEY (charge_id) REFERENCES public.charges(id);


--
-- Name: lesson_sessions lesson_sessions_counter_slot_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_counter_slot_id_fkey FOREIGN KEY (counter_slot_id) REFERENCES public.lesson_booking_slots(id);


--
-- Name: lesson_sessions lesson_sessions_counterer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_counterer_id_fkey FOREIGN KEY (counterer_id) REFERENCES public.users(id);


--
-- Name: lesson_sessions lesson_sessions_lesson_booking_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_lesson_booking_id_fkey FOREIGN KEY (lesson_booking_id) REFERENCES public.lesson_bookings(id);


--
-- Name: lesson_sessions lesson_sessions_lesson_package_purchase_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_lesson_package_purchase_id_fkey FOREIGN KEY (lesson_package_purchase_id) REFERENCES public.lesson_package_purchases(id);


--
-- Name: lesson_sessions lesson_sessions_slot_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_slot_id_fkey FOREIGN KEY (slot_id) REFERENCES public.lesson_booking_slots(id) ON DELETE CASCADE;


--
-- Name: lesson_sessions lesson_sessions_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.users(id);


--
-- Name: lesson_sessions lesson_sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.lesson_sessions
    ADD CONSTRAINT lesson_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: likes likes_user_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.likes
    ADD CONSTRAINT likes_user_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: live_streams live_streams_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.live_streams
    ADD CONSTRAINT live_streams_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE SET NULL;


--
-- Name: live_streams live_streams_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.live_streams
    ADD CONSTRAINT live_streams_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: machine_extras machine_extras_machine_fingerprint_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.machine_extras
    ADD CONSTRAINT machine_extras_machine_fingerprint_id_fkey FOREIGN KEY (machine_fingerprint_id) REFERENCES public.machine_fingerprints(id) ON DELETE CASCADE;


--
-- Name: machine_fingerprints machine_fingerprints_jam_track_right_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.machine_fingerprints
    ADD CONSTRAINT machine_fingerprints_jam_track_right_id_fkey FOREIGN KEY (jam_track_right_id) REFERENCES public.jam_track_rights(id) ON DELETE SET NULL;


--
-- Name: machine_fingerprints machine_fingerprints_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.machine_fingerprints
    ADD CONSTRAINT machine_fingerprints_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: mixes mixes_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.mixes
    ADD CONSTRAINT mixes_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: music_notations music_notations_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_notations
    ADD CONSTRAINT music_notations_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: music_notations music_notations_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_notations
    ADD CONSTRAINT music_notations_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: music_sessions_comments music_sessions_comments_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_comments
    ADD CONSTRAINT music_sessions_comments_creator_id_fkey FOREIGN KEY (creator_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: music_sessions_comments music_sessions_comments_music_session_id2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_comments
    ADD CONSTRAINT music_sessions_comments_music_session_id2_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: music_sessions music_sessions_history_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_history_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE CASCADE;


--
-- Name: music_sessions music_sessions_history_genre_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_history_genre_id_fkey FOREIGN KEY (genre_id) REFERENCES public.genres(id);


--
-- Name: music_sessions music_sessions_history_recurring_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_history_recurring_session_id_fkey FOREIGN KEY (recurring_session_id) REFERENCES public.recurring_sessions(id);


--
-- Name: music_sessions music_sessions_history_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_history_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: music_sessions music_sessions_lesson_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_lesson_session_id_fkey FOREIGN KEY (lesson_session_id) REFERENCES public.lesson_sessions(id) ON DELETE SET NULL;


--
-- Name: music_sessions_likers music_sessions_likers_liker_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_likers
    ADD CONSTRAINT music_sessions_likers_liker_id_fkey FOREIGN KEY (liker_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: music_sessions_likers music_sessions_likers_music_session_id2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_likers
    ADD CONSTRAINT music_sessions_likers_music_session_id2_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: music_sessions music_sessions_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: music_sessions music_sessions_session_controller_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions
    ADD CONSTRAINT music_sessions_session_controller_id_fkey FOREIGN KEY (session_controller_id) REFERENCES public.users(id);


--
-- Name: music_sessions_user_history music_sessions_user_history_music_session_id2_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_user_history
    ADD CONSTRAINT music_sessions_user_history_music_session_id2_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: music_sessions_user_history music_sessions_user_history_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.music_sessions_user_history
    ADD CONSTRAINT music_sessions_user_history_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: musicians_instruments musicians_instruments_instrument_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.musicians_instruments
    ADD CONSTRAINT musicians_instruments_instrument_id_fkey FOREIGN KEY (instrument_id) REFERENCES public.instruments(id) ON DELETE CASCADE;


--
-- Name: claimed_recordings musicians_recordings_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.claimed_recordings
    ADD CONSTRAINT musicians_recordings_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: claimed_recordings musicians_recordings_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.claimed_recordings
    ADD CONSTRAINT musicians_recordings_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_band_invitation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_band_invitation_id_fkey FOREIGN KEY (band_invitation_id) REFERENCES public.band_invitations(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_friend_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_friend_request_id_fkey FOREIGN KEY (friend_request_id) REFERENCES public.friend_requests(id);


--
-- Name: notifications notifications_jam_track_mixdown_package_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_jam_track_mixdown_package_id_fkey FOREIGN KEY (jam_track_mixdown_package_id) REFERENCES public.jam_track_mixdown_packages(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_jam_track_right_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_jam_track_right_id_fkey FOREIGN KEY (jam_track_right_id) REFERENCES public.jam_track_rights(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_lesson_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_lesson_session_id_fkey FOREIGN KEY (lesson_session_id) REFERENCES public.lesson_sessions(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_source_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_source_user_id_fkey FOREIGN KEY (source_user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: notifications notifications_target_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.notifications
    ADD CONSTRAINT notifications_target_user_id_fkey FOREIGN KEY (target_user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: performance_samples performance_samples_claimed_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.performance_samples
    ADD CONSTRAINT performance_samples_claimed_recording_id_fkey FOREIGN KEY (claimed_recording_id) REFERENCES public.claimed_recordings(id) ON DELETE CASCADE;


--
-- Name: playable_plays playable_plays_claimed_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.playable_plays
    ADD CONSTRAINT playable_plays_claimed_recording_id_fkey FOREIGN KEY (claimed_recording_id) REFERENCES public.claimed_recordings(id) ON DELETE CASCADE;


--
-- Name: playable_plays playable_plays_player_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.playable_plays
    ADD CONSTRAINT playable_plays_player_id_fkey FOREIGN KEY (player_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: posa_card_purchases posa_card_purchases_posa_card_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_card_purchases
    ADD CONSTRAINT posa_card_purchases_posa_card_id_fkey FOREIGN KEY (posa_card_id) REFERENCES public.posa_cards(id) ON DELETE SET NULL;


--
-- Name: posa_card_purchases posa_card_purchases_posa_card_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_card_purchases
    ADD CONSTRAINT posa_card_purchases_posa_card_type_id_fkey FOREIGN KEY (posa_card_type_id) REFERENCES public.posa_card_types(id) ON DELETE SET NULL;


--
-- Name: posa_card_purchases posa_card_purchases_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_card_purchases
    ADD CONSTRAINT posa_card_purchases_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: posa_cards posa_cards_lesson_package_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_cards
    ADD CONSTRAINT posa_cards_lesson_package_type_id_fkey FOREIGN KEY (lesson_package_type_id) REFERENCES public.lesson_package_types(id) ON DELETE SET NULL;


--
-- Name: posa_cards posa_cards_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_cards
    ADD CONSTRAINT posa_cards_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id) ON DELETE SET NULL;


--
-- Name: posa_cards posa_cards_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.posa_cards
    ADD CONSTRAINT posa_cards_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: quick_mixes quick_mixes_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.quick_mixes
    ADD CONSTRAINT quick_mixes_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: quick_mixes quick_mixes_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.quick_mixes
    ADD CONSTRAINT quick_mixes_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: recorded_backing_tracks recorded_backing_tracks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_backing_tracks
    ADD CONSTRAINT recorded_backing_tracks_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recorded_jam_track_tracks recorded_jam_track_tracks_jam_track_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_jam_track_tracks
    ADD CONSTRAINT recorded_jam_track_tracks_jam_track_track_id_fkey FOREIGN KEY (jam_track_track_id) REFERENCES public.jam_track_tracks(id);


--
-- Name: recorded_jam_track_tracks recorded_jam_track_tracks_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_jam_track_tracks
    ADD CONSTRAINT recorded_jam_track_tracks_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id);


--
-- Name: recorded_jam_track_tracks recorded_jam_track_tracks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_jam_track_tracks
    ADD CONSTRAINT recorded_jam_track_tracks_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recorded_tracks recorded_tracks_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_tracks
    ADD CONSTRAINT recorded_tracks_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: recorded_videos recorded_videos_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_videos
    ADD CONSTRAINT recorded_videos_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recordings recordings_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings
    ADD CONSTRAINT recordings_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id);


--
-- Name: recordings_comments recordings_comments_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_comments
    ADD CONSTRAINT recordings_comments_creator_id_fkey FOREIGN KEY (creator_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recordings_comments recordings_comments_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_comments
    ADD CONSTRAINT recordings_comments_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: recordings recordings_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings
    ADD CONSTRAINT recordings_creator_id_fkey FOREIGN KEY (owner_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recordings_downloads recordings_downloads_downloader_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_downloads
    ADD CONSTRAINT recordings_downloads_downloader_id_fkey FOREIGN KEY (downloader_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recordings_downloads recordings_downloads_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_downloads
    ADD CONSTRAINT recordings_downloads_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: recordings recordings_first_quick_mix_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings
    ADD CONSTRAINT recordings_first_quick_mix_id_fkey FOREIGN KEY (first_quick_mix_id) REFERENCES public.quick_mixes(id) ON DELETE SET NULL;


--
-- Name: recordings recordings_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings
    ADD CONSTRAINT recordings_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id);


--
-- Name: recordings recordings_jam_track_initiator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings
    ADD CONSTRAINT recordings_jam_track_initiator_id_fkey FOREIGN KEY (jam_track_initiator_id) REFERENCES public.users(id);


--
-- Name: recordings_likers recordings_likers_claimed_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_likers
    ADD CONSTRAINT recordings_likers_claimed_recording_id_fkey FOREIGN KEY (claimed_recording_id) REFERENCES public.claimed_recordings(id);


--
-- Name: recordings_likers recordings_likers_liker_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_likers
    ADD CONSTRAINT recordings_likers_liker_id_fkey FOREIGN KEY (liker_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recordings_likers recordings_likers_recording_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recordings_likers
    ADD CONSTRAINT recordings_likers_recording_id_fkey FOREIGN KEY (recording_id) REFERENCES public.recordings(id) ON DELETE CASCADE;


--
-- Name: recurly_transaction_web_hooks recurly_transaction_web_hooks_jam_track_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurly_transaction_web_hooks
    ADD CONSTRAINT recurly_transaction_web_hooks_jam_track_id_fkey FOREIGN KEY (jam_track_id) REFERENCES public.jam_tracks(id);


--
-- Name: recurly_transaction_web_hooks recurly_transaction_web_hooks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurly_transaction_web_hooks
    ADD CONSTRAINT recurly_transaction_web_hooks_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recurring_sessions recurring_sessions_band_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurring_sessions
    ADD CONSTRAINT recurring_sessions_band_id_fkey FOREIGN KEY (band_id) REFERENCES public.bands(id) ON DELETE CASCADE;


--
-- Name: recurring_sessions recurring_sessions_genre_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurring_sessions
    ADD CONSTRAINT recurring_sessions_genre_id_fkey FOREIGN KEY (genre_id) REFERENCES public.genres(id);


--
-- Name: recurring_sessions recurring_sessions_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recurring_sessions
    ADD CONSTRAINT recurring_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: retailer_invitations retailer_invitations_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailer_invitations
    ADD CONSTRAINT retailer_invitations_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: retailer_invitations retailer_invitations_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailer_invitations
    ADD CONSTRAINT retailer_invitations_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: retailers retailers_affiliate_partner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailers
    ADD CONSTRAINT retailers_affiliate_partner_id_fkey FOREIGN KEY (affiliate_partner_id) REFERENCES public.affiliate_partners(id);


--
-- Name: retailers retailers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.retailers
    ADD CONSTRAINT retailers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: reviews reviews_deleted_by_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_deleted_by_user_id_fkey FOREIGN KEY (deleted_by_user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: reviews reviews_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.reviews
    ADD CONSTRAINT reviews_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: rsvp_requests rsvp_requests_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_requests
    ADD CONSTRAINT rsvp_requests_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id);


--
-- Name: rsvp_requests_rsvp_slots rsvp_requests_rsvp_slots_rsvp_request_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_requests_rsvp_slots
    ADD CONSTRAINT rsvp_requests_rsvp_slots_rsvp_request_id_fkey FOREIGN KEY (rsvp_request_id) REFERENCES public.rsvp_requests(id) ON DELETE CASCADE;


--
-- Name: rsvp_requests_rsvp_slots rsvp_requests_rsvp_slots_rsvp_slot_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_requests_rsvp_slots
    ADD CONSTRAINT rsvp_requests_rsvp_slots_rsvp_slot_id_fkey FOREIGN KEY (rsvp_slot_id) REFERENCES public.rsvp_slots(id) ON DELETE CASCADE;


--
-- Name: rsvp_requests rsvp_requests_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_requests
    ADD CONSTRAINT rsvp_requests_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: rsvp_slots rsvp_slots_instrument_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_slots
    ADD CONSTRAINT rsvp_slots_instrument_id_fkey FOREIGN KEY (instrument_id) REFERENCES public.instruments(id) ON DELETE SET NULL;


--
-- Name: rsvp_slots rsvp_slots_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.rsvp_slots
    ADD CONSTRAINT rsvp_slots_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: sale_line_items sale_line_items_affiliate_referral_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_affiliate_referral_id_fkey FOREIGN KEY (affiliate_referral_id) REFERENCES public.affiliate_partners(id);


--
-- Name: sale_line_items sale_line_items_gift_card_purchase_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_gift_card_purchase_id_fkey FOREIGN KEY (gift_card_purchase_id) REFERENCES public.gift_card_purchases(id);


--
-- Name: sale_line_items sale_line_items_lesson_package_purchase_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_lesson_package_purchase_id_fkey FOREIGN KEY (lesson_package_purchase_id) REFERENCES public.lesson_package_purchases(id);


--
-- Name: sale_line_items sale_line_items_posa_card_purchase_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_posa_card_purchase_id_fkey FOREIGN KEY (posa_card_purchase_id) REFERENCES public.posa_card_purchases(id);


--
-- Name: sale_line_items sale_line_items_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: sale_line_items sale_line_items_sale_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sale_line_items
    ADD CONSTRAINT sale_line_items_sale_id_fkey FOREIGN KEY (sale_id) REFERENCES public.sales(id) ON DELETE CASCADE;


--
-- Name: sales sales_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sales
    ADD CONSTRAINT sales_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: sales sales_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.sales
    ADD CONSTRAINT sales_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: recorded_tracks saved_tracks_instrument_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_tracks
    ADD CONSTRAINT saved_tracks_instrument_id_fkey FOREIGN KEY (instrument_id) REFERENCES public.instruments(id) ON DELETE CASCADE;


--
-- Name: recorded_tracks saved_tracks_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.recorded_tracks
    ADD CONSTRAINT saved_tracks_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: school_invitations school_invitations_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.school_invitations
    ADD CONSTRAINT school_invitations_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: school_invitations school_invitations_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.school_invitations
    ADD CONSTRAINT school_invitations_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: schools schools_affiliate_partner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schools
    ADD CONSTRAINT schools_affiliate_partner_id_fkey FOREIGN KEY (affiliate_partner_id) REFERENCES public.affiliate_partners(id);


--
-- Name: schools schools_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schools
    ADD CONSTRAINT schools_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: session_info_comments session_info_comments_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.session_info_comments
    ADD CONSTRAINT session_info_comments_creator_id_fkey FOREIGN KEY (creator_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: session_info_comments session_info_comments_music_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.session_info_comments
    ADD CONSTRAINT session_info_comments_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES public.music_sessions(id) ON DELETE CASCADE;


--
-- Name: shopping_carts shopping_carts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.shopping_carts
    ADD CONSTRAINT shopping_carts_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: signup_hints signup_hints_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.signup_hints
    ADD CONSTRAINT signup_hints_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: teacher_distributions teacher_distributions_lesson_package_purchase_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_lesson_package_purchase_id_fkey FOREIGN KEY (lesson_package_purchase_id) REFERENCES public.lesson_package_purchases(id);


--
-- Name: teacher_distributions teacher_distributions_lesson_session_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_lesson_session_id_fkey FOREIGN KEY (lesson_session_id) REFERENCES public.lesson_sessions(id);


--
-- Name: teacher_distributions teacher_distributions_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: teacher_distributions teacher_distributions_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: teacher_distributions teacher_distributions_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.users(id);


--
-- Name: teacher_distributions teacher_distributions_teacher_payment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_distributions
    ADD CONSTRAINT teacher_distributions_teacher_payment_id_fkey FOREIGN KEY (teacher_payment_id) REFERENCES public.teacher_payments(id);


--
-- Name: teacher_experiences teacher_experiences_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_experiences
    ADD CONSTRAINT teacher_experiences_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;


--
-- Name: teacher_intents teacher_intents_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_intents
    ADD CONSTRAINT teacher_intents_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id);


--
-- Name: teacher_intents teacher_intents_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_intents
    ADD CONSTRAINT teacher_intents_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);


--
-- Name: teacher_payments teacher_payments_charge_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_payments
    ADD CONSTRAINT teacher_payments_charge_id_fkey FOREIGN KEY (charge_id) REFERENCES public.charges(id);


--
-- Name: teacher_payments teacher_payments_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_payments
    ADD CONSTRAINT teacher_payments_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: teacher_payments teacher_payments_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_payments
    ADD CONSTRAINT teacher_payments_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: teacher_payments teacher_payments_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teacher_payments
    ADD CONSTRAINT teacher_payments_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.users(id);


--
-- Name: teachers_genres teachers_genres_genre_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_genres
    ADD CONSTRAINT teachers_genres_genre_id_fkey FOREIGN KEY (genre_id) REFERENCES public.genres(id) ON DELETE CASCADE;


--
-- Name: teachers_genres teachers_genres_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_genres
    ADD CONSTRAINT teachers_genres_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;


--
-- Name: teachers_instruments teachers_instruments_instrument_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_instruments
    ADD CONSTRAINT teachers_instruments_instrument_id_fkey FOREIGN KEY (instrument_id) REFERENCES public.instruments(id) ON DELETE CASCADE;


--
-- Name: teachers_instruments teachers_instruments_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_instruments
    ADD CONSTRAINT teachers_instruments_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;


--
-- Name: teachers_languages teachers_languages_language_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_languages
    ADD CONSTRAINT teachers_languages_language_id_fkey FOREIGN KEY (language_id) REFERENCES public.languages(id) ON DELETE CASCADE;


--
-- Name: teachers_languages teachers_languages_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_languages
    ADD CONSTRAINT teachers_languages_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;


--
-- Name: teachers teachers_retailer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers
    ADD CONSTRAINT teachers_retailer_id_fkey FOREIGN KEY (retailer_id) REFERENCES public.retailers(id);


--
-- Name: teachers teachers_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers
    ADD CONSTRAINT teachers_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: teachers_subjects teachers_subjects_subject_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_subjects
    ADD CONSTRAINT teachers_subjects_subject_id_fkey FOREIGN KEY (subject_id) REFERENCES public.subjects(id) ON DELETE CASCADE;


--
-- Name: teachers_subjects teachers_subjects_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.teachers_subjects
    ADD CONSTRAINT teachers_subjects_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;


--
-- Name: test_drive_package_choice_teachers test_drive_package_choice_tea_test_drive_package_choice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_choice_teachers
    ADD CONSTRAINT test_drive_package_choice_tea_test_drive_package_choice_id_fkey FOREIGN KEY (test_drive_package_choice_id) REFERENCES public.test_drive_package_choices(id) ON DELETE CASCADE;


--
-- Name: test_drive_package_choice_teachers test_drive_package_choice_teachers_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_choice_teachers
    ADD CONSTRAINT test_drive_package_choice_teachers_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: test_drive_package_choices test_drive_package_choices_test_drive_package_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_choices
    ADD CONSTRAINT test_drive_package_choices_test_drive_package_id_fkey FOREIGN KEY (test_drive_package_id) REFERENCES public.test_drive_packages(id) ON DELETE CASCADE;


--
-- Name: test_drive_package_choices test_drive_package_choices_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_choices
    ADD CONSTRAINT test_drive_package_choices_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: test_drive_package_teachers test_drive_package_teachers_test_drive_package_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_teachers
    ADD CONSTRAINT test_drive_package_teachers_test_drive_package_id_fkey FOREIGN KEY (test_drive_package_id) REFERENCES public.test_drive_packages(id) ON DELETE CASCADE;


--
-- Name: test_drive_package_teachers test_drive_package_teachers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.test_drive_package_teachers
    ADD CONSTRAINT test_drive_package_teachers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: text_messages text_messages_source_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.text_messages
    ADD CONSTRAINT text_messages_source_user_id_fkey FOREIGN KEY (source_user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: text_messages text_messages_target_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.text_messages
    ADD CONSTRAINT text_messages_target_user_id_fkey FOREIGN KEY (target_user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: user_authorizations user_authorizations_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_authorizations
    ADD CONSTRAINT user_authorizations_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: user_blacklists user_blacklists_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_blacklists
    ADD CONSTRAINT user_blacklists_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: user_events user_events_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_events
    ADD CONSTRAINT user_events_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: user_whitelists user_whitelists_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.user_whitelists
    ADD CONSTRAINT user_whitelists_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;


--
-- Name: users users_affiliate_referral_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_affiliate_referral_id_fkey FOREIGN KEY (affiliate_referral_id) REFERENCES public.affiliate_partners(id) ON DELETE SET NULL;


--
-- Name: users users_icecast_server_group_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_icecast_server_group_id_fkey FOREIGN KEY (icecast_server_group_id) REFERENCES public.icecast_server_groups(id);


--
-- Name: users users_lesson_package_needs_purchase_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_lesson_package_needs_purchase_id_fkey FOREIGN KEY (lesson_package_needs_purchase_id) REFERENCES public.lesson_package_types(id) ON DELETE SET NULL;


--
-- Name: users users_lesson_package_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_lesson_package_type_id_fkey FOREIGN KEY (lesson_package_type_id) REFERENCES public.lesson_package_types(id);


--
-- Name: users users_onboarder_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_onboarder_id_fkey FOREIGN KEY (onboarder_id) REFERENCES public.users(id) ON DELETE SET NULL;


--
-- Name: users users_school_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_school_id_fkey FOREIGN KEY (school_id) REFERENCES public.schools(id);


--
-- Name: users users_teacher_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.users
    ADD CONSTRAINT users_teacher_id_fkey FOREIGN KEY (teacher_id) REFERENCES public.teachers(id) ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--


--
-- ############# Insert initial setup data ################
--

--
-- Data for Name: pg_migrate; Type: TABLE DATA; Schema: pgmigrate; Owner: postgres
--

INSERT INTO pgmigrate.pg_migrate VALUES (1, '0.1.0', 'pg_migrate_ruby-0.1.14', 'pg_migrate_ruby-0.1.14', 'PostgreSQL 9.3.25 on x86_64-pc-linux-gnu (Ubuntu 9.3.25-3.pgdg20.04+1), compiled by gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0, 64-bit');


--
-- Name: pg_migrate_id_seq; Type: SEQUENCE SET; Schema: pgmigrate; Owner: postgres
--

SELECT pg_catalog.setval('pgmigrate.pg_migrate_id_seq', 1, true);


--
-- Data for Name: active_admin_comments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: active_admin_comments_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.active_admin_comments_id_seq', 1, false);


--
-- Data for Name: icecast_server_groups; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.icecast_server_groups VALUES ('default', 'default');
INSERT INTO public.icecast_server_groups VALUES ('unused', 'unused');


--
-- Data for Name: lesson_package_types; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.lesson_package_types VALUES ('test-drive-2', 'Test Drive (2)', 'Two reduced-price lessons which you can use to find that ideal teacher.', 'test-drive-2', 29.99, '2021-02-02 23:16:52.027835', '2021-02-02 23:16:52.027835', true);
INSERT INTO public.lesson_package_types VALUES ('test-drive-1', 'Test Drive (1)', 'One reduced-price lessons which you can use to find that ideal teacher.', 'test-drive-1', 15.99, '2021-02-02 23:16:52.027835', '2021-02-02 23:16:52.027835', true);
INSERT INTO public.lesson_package_types VALUES ('test-drive', 'Test Drive (4)', 'Four reduced-price lessons which you can use to find that ideal teacher.', 'test-drive-4', 49.99, '2021-02-02 23:16:51.715079', '2021-02-02 23:16:51.715079', true);
INSERT INTO public.lesson_package_types VALUES ('single', 'Single Lesson', 'A single lesson purchased at the teacher''s price.', 'single', 0.00, '2021-02-02 23:16:51.715079', '2021-02-02 23:16:51.715079', false);
INSERT INTO public.lesson_package_types VALUES ('single-free', 'Free Lesson', 'A free, single lesson.', 'single-free', 0.00, '2021-02-02 23:16:51.715079', '2021-02-02 23:16:51.715079', false);
INSERT INTO public.lesson_package_types VALUES ('amazon-test-drive-free-4', 'Test Drive (4)', 'Four free lessons which you can use to find that ideal teacher.', 'test-drive-4', 0.00, '2021-02-02 23:16:52.646325', '2021-02-02 23:16:52.646325', true);
INSERT INTO public.lesson_package_types VALUES ('amazon-test-drive-free-2', 'Test Drive (2)', 'Two free lessons which you can use to find that ideal teacher.', 'test-drive-2', 0.00, '2021-02-02 23:16:52.646325', '2021-02-02 23:16:52.646325', true);
INSERT INTO public.lesson_package_types VALUES ('amazon-test-drive-paid-4', 'Test Drive (4)', 'Four reduced-price lessons which you can use to find that ideal teacher.', 'test-drive-4', 19.99, '2021-02-02 23:16:52.646325', '2021-02-02 23:16:52.646325', true);


--
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.users VALUES ('1', 'test@jamkazam.com', 'NQubl-z16Em94tnSdofObw', '$2a$10$QyaNTLVX5DAaJ.JL21kDWeUQqdh3Qh7JQbdRgE82x1Cib7HWNcHXC', false, '2021-02-02 23:16:45.937298', '2021-02-02 23:16:52.075423', true, 'City', 'NC', 'US', 'Test', 'User', '1978-07-07', 'M', NULL, true, NULL, NULL, NULL, NULL, true, '''test'':1 ''user'':2', 'public', true, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, 'default', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL, NULL, NULL, false, NULL, false, NULL, NULL, false, NULL, NULL, false, false, NULL, true, true, 0, false, NULL, NULL, NULL, 0, false, NULL, false, NULL, false, false, NULL, 1, false, 0, NULL, NULL, NULL, NULL, NULL, false, NULL, false, 'legacy', NULL, NULL, NULL, 0, false, false, NULL, NULL, NULL, false, 'Unassigned', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, 0, NULL, 0, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, false, false, false, false, NULL, NULL, 0, NULL, NULL, false, false, NULL, NULL, NULL, NULL, NULL, NULL, 'jamsubplatinum', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, '2021-01-01 00:00:00', NULL, NULL, NULL);


--
-- Data for Name: affiliate_partners; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: schools; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: active_music_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: charges; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: gift_card_types; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.gift_card_types VALUES ('jam_tracks_5', 'jam_tracks_5', '2021-02-02 23:16:51.192305', '2021-02-02 23:16:51.192305');
INSERT INTO public.gift_card_types VALUES ('jam_tracks_10', 'jam_tracks_10', '2021-02-02 23:16:51.192305', '2021-02-02 23:16:51.192305');


--
-- Data for Name: gift_card_purchases; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: retailers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: test_drive_packages; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: test_drive_package_choices; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: lesson_bookings; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: lesson_package_purchases; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: posa_card_types; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.posa_card_types VALUES ('jam_tracks_5', 'jam_tracks_5', '2021-02-02 23:16:52.330105', '2021-02-02 23:16:52.330105');
INSERT INTO public.posa_card_types VALUES ('jam_tracks_10', 'jam_tracks_10', '2021-02-02 23:16:52.330105', '2021-02-02 23:16:52.330105');
INSERT INTO public.posa_card_types VALUES ('jam_class_10', 'jam_class_10', '2021-02-02 23:16:52.330105', '2021-02-02 23:16:52.330105');


--
-- Data for Name: posa_cards; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: posa_card_purchases; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: sales; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: sale_line_items; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: affiliate_distributions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: affiliate_legalese; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: affiliate_monthly_payments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: affiliate_quarterly_payments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: affiliate_referral_visits; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: affiliate_traffic_totals; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: arses; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: arses_id_int_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.arses_id_int_seq', 1, false);


--
-- Data for Name: artifact_updates; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: connections; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: backing_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: bands; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: band_invitations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: bands_musicians; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: broadcast_notifications; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: broadcast_notification_views; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: genres; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.genres VALUES ('african', 'African', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('ambient', 'Ambient', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('asian', 'Asian', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('blues', 'Blues', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('classical', 'Classical', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('country', 'Country', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('electronic', 'Electronic', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('folk', 'Folk', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('hip hop', 'Hip Hop', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('jazz', 'Jazz', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('latin', 'Latin', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('metal', 'Metal', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('pop', 'Pop', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('r&b', 'R&B', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('reggae', 'Reggae', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('religious', 'Religious', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('rock', 'Rock', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('ska', 'Ska', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('other', 'Other', '2021-02-02 23:16:46.139089', '2021-02-02 23:16:46.139089');
INSERT INTO public.genres VALUES ('alternative rock', 'Alternative Rock', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('americana', 'Americana', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('avante-garde', 'Avante-Garde', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('bluegrass', 'Bluegrass', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('breakbeat', 'Breakbeat', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('downtempo', 'Downtempo', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('drum & bass', 'Drum & Bass', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('house', 'House', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('industrial', 'Industrial', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('punk', 'Punk', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('psychedelic', 'Psychedelic', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('techno', 'Techno', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('trance', 'Trance', '2021-02-02 23:16:48.98329', '2021-02-02 23:16:48.98329');
INSERT INTO public.genres VALUES ('soft rock', 'Soft Rock', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('rap', 'Rap', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('tv & movie soundtrack', 'TV & Movie Soundtrack', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('holiday', 'Holiday', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('kids', 'Kids', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('disco', 'Disco', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('soul', 'Soul', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('hard rock', 'Hard Rock', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('funk', 'Funk', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('dance', 'Dance', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('creole', 'Creole', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('traditional', 'Traditional', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('oldies', 'Oldies', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('world', 'World', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('musical', 'Musical', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('celtic', 'Celtic', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814');
INSERT INTO public.genres VALUES ('acapella', 'A Cappella', '2021-02-02 23:16:51.184908', '2021-02-02 23:16:51.184908');


--
-- Data for Name: lesson_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recurring_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: music_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: broadcasts; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: calendars; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: campaign_spends; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_licensors; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.jam_track_licensors VALUES ('906b0bd9-7380-42a9-bd6a-e7d148f46081', 'Tency Music', 'Tency Music is a music production company specialized in re-recordings.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', NULL);


--
-- Data for Name: jam_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recordings; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: claimed_recordings; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: music_notations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: chat_messages; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: cities; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.cities VALUES ('Barstow', 'CA', 'US');
INSERT INTO public.cities VALUES ('Memphis', 'TN', 'US');
INSERT INTO public.cities VALUES ('Denver', 'CO', 'US');
INSERT INTO public.cities VALUES ('Dallas', 'TX', 'US');
INSERT INTO public.cities VALUES ('Mountain View', 'CA', 'US');
INSERT INTO public.cities VALUES ('Miami', 'FL', 'US');
INSERT INTO public.cities VALUES ('Austin', 'TX', 'US');
INSERT INTO public.cities VALUES ('Boston', 'MA', 'US');
INSERT INTO public.cities VALUES ('Mountain View', 'AR', 'US');
INSERT INTO public.cities VALUES ('Seattle', 'WA', 'US');
INSERT INTO public.cities VALUES ('Tampa', 'FL', 'US');
INSERT INTO public.cities VALUES ('Portland', 'ME', 'US');
INSERT INTO public.cities VALUES ('Houston', 'TX', 'US');
INSERT INTO public.cities VALUES ('Portland', 'OR', 'US');
INSERT INTO public.cities VALUES ('Tulsa', 'OK', 'US');
INSERT INTO public.cities VALUES ('San Antonio', 'TX', 'US');


--
-- Data for Name: client_live_streams; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: cohorts; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: connections_client_id_int_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.connections_client_id_int_seq', 1, false);


--
-- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.countries VALUES ('US', NULL);


--
-- Data for Name: crash_dumps; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: current_network_scores; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: diagnostics; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: download_trackers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: email_batches; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: email_batch_sets; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: email_blacklists; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: email_errors; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: event_brite_order_uploads; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: live_streams; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: event_brite_orders; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: events; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: event_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: facebook_signups; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: fan_invitations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: feeds; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: feeds_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.feeds_id_seq', 1, false);


--
-- Data for Name: fingerprint_whitelists; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: follows; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: instruments; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.instruments VALUES ('acoustic guitar', 'Acoustic Guitar', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('bass guitar', 'Bass Guitar', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('computer', 'Computer', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('drums', 'Drums', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('electric guitar', 'Electric Guitar', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('keyboard', 'Keyboard', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('voice', 'Voice', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 3);
INSERT INTO public.instruments VALUES ('flute', 'Flute', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('clarinet', 'Clarinet', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('saxophone', 'Saxophone', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('trumpet', 'Trumpet', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('violin', 'Violin', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('trombone', 'Trombone', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('banjo', 'Banjo', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('harmonica', 'Harmonica', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('accordion', 'Accordion', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 2);
INSERT INTO public.instruments VALUES ('french horn', 'French Horn', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('euphonium', 'Euphonium', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('tuba', 'Tuba', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('oboe', 'Oboe', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('ukulele', 'Ukulele', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('cello', 'Cello', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('viola', 'Viola', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('mandolin', 'Mandolin', '2021-02-02 23:16:46.168487', '2021-02-02 23:16:46.168487', 1);
INSERT INTO public.instruments VALUES ('other', 'Other', '2021-02-02 23:16:46.925442', '2021-02-02 23:16:46.925442', 1);
INSERT INTO public.instruments VALUES ('piano', 'Piano', '2021-02-02 23:16:47.744181', '2021-02-02 23:16:47.744181', 2);
INSERT INTO public.instruments VALUES ('double bass', 'Double Bass', '2021-02-02 23:16:47.887097', '2021-02-02 23:16:47.887097', 2);
INSERT INTO public.instruments VALUES ('steel guitar', 'Steel Guitar', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('orchestra', 'Orchestra', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('glockenspiel', 'Glockenspiel', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('dobro', 'Dobro', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('harp', 'Harp', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('vocoder', 'Vocoder', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('flugelhorn', 'Flugelhorn', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('timpani', 'Timpani', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('bassoon', 'Bassoon', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('charango', 'Charango', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('theremin', 'Theremin', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('sitar', 'Sitar', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('piccolo', 'Piccolo', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('bagpipes', 'Bagpipes', '2021-02-02 23:16:50.776814', '2021-02-02 23:16:50.776814', 1);
INSERT INTO public.instruments VALUES ('percussion', 'Percussion', '2021-02-02 23:16:51.235733', '2021-02-02 23:16:51.235733', 0);


--
-- Data for Name: jam_track_mixdowns; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_rights; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: machine_fingerprints; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: fraud_alerts; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: friend_requests; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: friendships; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: generic_state; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.generic_state VALUES ('default', '1900-01-01 00:00:00', 'development', NULL, '2021-02-02', NULL, '/assets/event/eventbrite-logo.png', NULL);


--
-- Data for Name: genre_players; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: genres_jam_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: genres_music_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: gift_cards; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_admin_authentications; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_directories; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_limits; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_listen_sockets; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_loggings; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_master_server_relays; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_mount_templates; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_paths; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_securities; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_templates; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_servers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_mounts; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_relays; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_server_mounts; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_server_relays; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_server_sockets; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_source_changes; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_template_sockets; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: icecast_user_authentications; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: join_requests; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: invitations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: invited_users; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: ip_blacklists; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: ip_whitelists; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: isp_score_batch; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_class_reports; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_files; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_hfa_requests; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_hfa_request_ids; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: jam_track_hfa_requests_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.jam_track_hfa_requests_id_seq', 1, false);


--
-- Data for Name: jam_track_mixdown_packages; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_sessions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jam_track_tap_ins; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: jam_tracks_next_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.jam_tracks_next_seq', 1, false);


--
-- Data for Name: jamblasters; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jamblaster_pairing_requests; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: jamblasters_users; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: jamcompany_coid_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.jamcompany_coid_seq', 4, true);


--
-- Data for Name: json_stores; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: languages; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.languages VALUES ('EN', 'English');
INSERT INTO public.languages VALUES ('AF', 'Afrikanns');
INSERT INTO public.languages VALUES ('SQ', 'Albanian');
INSERT INTO public.languages VALUES ('AR', 'Arabic');
INSERT INTO public.languages VALUES ('HY', 'Armenian');
INSERT INTO public.languages VALUES ('EU', 'Basque');
INSERT INTO public.languages VALUES ('BN', 'Bengali');
INSERT INTO public.languages VALUES ('BG', 'Bulgarian');
INSERT INTO public.languages VALUES ('CA', 'Catalan');
INSERT INTO public.languages VALUES ('KM', 'Cambodian');
INSERT INTO public.languages VALUES ('ZH', 'Chinese (Mandarin)');
INSERT INTO public.languages VALUES ('HR', 'Croation');
INSERT INTO public.languages VALUES ('CS', 'Czech');
INSERT INTO public.languages VALUES ('DA', 'Danish');
INSERT INTO public.languages VALUES ('NL', 'Dutch');
INSERT INTO public.languages VALUES ('ET', 'Estonian');
INSERT INTO public.languages VALUES ('FJ', 'Fiji');
INSERT INTO public.languages VALUES ('FI', 'Finnish');
INSERT INTO public.languages VALUES ('FR', 'French');
INSERT INTO public.languages VALUES ('KA', 'Georgian');
INSERT INTO public.languages VALUES ('DE', 'German');
INSERT INTO public.languages VALUES ('EL', 'Greek');
INSERT INTO public.languages VALUES ('GU', 'Gujarati');
INSERT INTO public.languages VALUES ('HE', 'Hebrew');
INSERT INTO public.languages VALUES ('HI', 'Hindi');
INSERT INTO public.languages VALUES ('HU', 'Hungarian');
INSERT INTO public.languages VALUES ('IS', 'Icelandic');
INSERT INTO public.languages VALUES ('ID', 'Indonesian');
INSERT INTO public.languages VALUES ('GA', 'Irish');
INSERT INTO public.languages VALUES ('IT', 'Italian');
INSERT INTO public.languages VALUES ('JA', 'Japanese');
INSERT INTO public.languages VALUES ('JW', 'Javanese');
INSERT INTO public.languages VALUES ('KO', 'Korean');
INSERT INTO public.languages VALUES ('LA', 'Latin');
INSERT INTO public.languages VALUES ('LV', 'Latvian');
INSERT INTO public.languages VALUES ('LT', 'Lithuanian');
INSERT INTO public.languages VALUES ('MK', 'Macedonian');
INSERT INTO public.languages VALUES ('MS', 'Malay');
INSERT INTO public.languages VALUES ('ML', 'Malayalam');
INSERT INTO public.languages VALUES ('MT', 'Maltese');
INSERT INTO public.languages VALUES ('MI', 'Maori');
INSERT INTO public.languages VALUES ('MR', 'Marathi');
INSERT INTO public.languages VALUES ('MN', 'Mongolian');
INSERT INTO public.languages VALUES ('NE', 'Nepali');
INSERT INTO public.languages VALUES ('NO', 'Norwegian');
INSERT INTO public.languages VALUES ('FA', 'Persian');
INSERT INTO public.languages VALUES ('PL', 'Polish');
INSERT INTO public.languages VALUES ('PT', 'Portuguese');
INSERT INTO public.languages VALUES ('PA', 'Punjabi');
INSERT INTO public.languages VALUES ('QU', 'Quechua');
INSERT INTO public.languages VALUES ('RO', 'Romanian');
INSERT INTO public.languages VALUES ('RU', 'Russian');
INSERT INTO public.languages VALUES ('SM', 'Samoan');
INSERT INTO public.languages VALUES ('SR', 'Serbian');
INSERT INTO public.languages VALUES ('SK', 'Slovak');
INSERT INTO public.languages VALUES ('SL', 'Slovenian');
INSERT INTO public.languages VALUES ('ES', 'Spanish');
INSERT INTO public.languages VALUES ('SW', 'Swahili');
INSERT INTO public.languages VALUES ('SV', 'Swedish ');
INSERT INTO public.languages VALUES ('TA', 'Tamil');
INSERT INTO public.languages VALUES ('TT', 'Tatar');
INSERT INTO public.languages VALUES ('TE', 'Telugu');
INSERT INTO public.languages VALUES ('TH', 'Thai');
INSERT INTO public.languages VALUES ('BO', 'Tibetan');
INSERT INTO public.languages VALUES ('TO', 'Tonga');
INSERT INTO public.languages VALUES ('TR', 'Turkish');
INSERT INTO public.languages VALUES ('UK', 'Ukranian');
INSERT INTO public.languages VALUES ('UR', 'Urdu');
INSERT INTO public.languages VALUES ('UZ', 'Uzbek');
INSERT INTO public.languages VALUES ('VI', 'Vietnamese');
INSERT INTO public.languages VALUES ('CY', 'Welsh');
INSERT INTO public.languages VALUES ('XH', 'Xhosa');


--
-- Data for Name: latency_testers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: lesson_booking_slots; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: likes; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: machine_extras; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: mixes; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: mobile_recording_uploads; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: music_session_perf_data; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: music_sessions_comments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: music_sessions_id_int_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.music_sessions_id_int_seq', 1, false);


--
-- Data for Name: music_sessions_likers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: music_sessions_user_history; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: musicians_instruments; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.musicians_instruments VALUES ('70ff1b44-cb52-48e1-8ba7-bc3c6ada4c98', '4fc1bad2-57b6-4f4f-9ae9-f84a544c2304', 'acoustic guitar', 3, 1, '2021-02-02 17:52:10.135063', '2021-02-02 17:52:10.135063', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('81eb63bd-002f-4a53-b943-3759e4d26add', '9df32f57-1ed3-4263-b5aa-d215b86a7812', 'acoustic guitar', 3, 1, '2021-02-02 17:52:10.279745', '2021-02-02 17:52:10.279745', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('7285308e-659d-451e-bb2e-e1d901f31911', 'e63bcb0d-5542-4427-95a4-ac4aeceb2172', 'acoustic guitar', 3, 1, '2021-02-02 17:52:10.443766', '2021-02-02 17:52:10.443766', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('07d1a951-6644-4646-bffe-bcdfbe8913aa', '6311725a-bdee-4ad4-9cb3-d4406a9de0cb', 'acoustic guitar', 3, 1, '2021-02-02 17:52:10.591348', '2021-02-02 17:52:10.591348', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('efd59f6a-d344-4a66-bf8c-26d8b78616f4', '0a837501-59e3-4df9-8a5c-67114912ee58', 'acoustic guitar', 3, 1, '2021-02-02 17:52:10.752623', '2021-02-02 17:52:10.752623', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('aea694be-3c42-4349-b974-c8b987c13d2b', 'b48ebda3-bde7-4694-a56a-8fc286db1ca8', 'acoustic guitar', 3, 1, '2021-02-02 17:52:10.910453', '2021-02-02 17:52:10.910453', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('9570a99e-5064-44af-aeb7-719b9ce3be5f', '8ff520b9-d757-4437-b1ca-fc4812e12112', 'acoustic guitar', 3, 1, '2021-02-02 18:47:06.534476', '2021-02-02 18:47:06.534476', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('ad732da6-c85f-4133-b329-8d86b7fcf704', '3db37474-bdf1-4188-bcfc-cd673efdab68', 'acoustic guitar', 3, 1, '2021-02-02 18:47:06.654107', '2021-02-02 18:47:06.654107', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('08f85991-6727-412c-819a-6bbc05a22405', '0a14f0f9-4be8-4671-a314-e9dfdf60d652', 'acoustic guitar', 3, 1, '2021-02-02 18:47:06.769202', '2021-02-02 18:47:06.769202', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('b8568b79-4b7d-4a7b-8727-1aaec12151f3', 'a99ebe2f-1ff2-4348-89a8-1892938a34c6', 'acoustic guitar', 3, 1, '2021-02-02 18:47:06.884059', '2021-02-02 18:47:06.884059', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('ff77d43c-56f8-4b48-bd11-351732f7e9d1', 'd053e319-1f93-4fe5-8879-c662b3d468e9', 'acoustic guitar', 3, 1, '2021-02-02 18:47:07.007998', '2021-02-02 18:47:07.007998', 'JamRuby::User');
INSERT INTO public.musicians_instruments VALUES ('3cb80ce9-abb0-47d4-b65b-60028d408920', 'd2685039-0f5d-4d61-a718-03b99296db75', 'acoustic guitar', 3, 1, '2021-02-02 18:47:07.144457', '2021-02-02 18:47:07.144457', 'JamRuby::User');


--
-- Data for Name: news; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: notifications; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: online_presences; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: partner_key_sequence; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.partner_key_sequence', 10000, false);


--
-- Data for Name: performance_samples; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: playable_plays; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: promotionals; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: quick_mixes; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recorded_backing_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recorded_jam_track_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recorded_tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recorded_videos; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recordings_comments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recordings_downloads; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recordings_likers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: recurly_transaction_web_hooks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: regions; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.regions VALUES ('TN', NULL, 'US');
INSERT INTO public.regions VALUES ('ME', NULL, 'US');
INSERT INTO public.regions VALUES ('MA', NULL, 'US');
INSERT INTO public.regions VALUES ('TX', NULL, 'US');
INSERT INTO public.regions VALUES ('OK', NULL, 'US');
INSERT INTO public.regions VALUES ('WA', NULL, 'US');
INSERT INTO public.regions VALUES ('CO', NULL, 'US');
INSERT INTO public.regions VALUES ('CA', NULL, 'US');
INSERT INTO public.regions VALUES ('AR', NULL, 'US');
INSERT INTO public.regions VALUES ('FL', NULL, 'US');
INSERT INTO public.regions VALUES ('OR', NULL, 'US');


--
-- Data for Name: retailer_invitations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: retailer_key_sequence; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.retailer_key_sequence', 10000, false);


--
-- Data for Name: review_summaries; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: reviews; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: rsvp_requests; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: rsvp_slots; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: rsvp_requests_rsvp_slots; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: school_invitations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: school_key_sequence; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.school_key_sequence', 10000, false);


--
-- Data for Name: score_histories; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: scores; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: session_info_comments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: share_tokens; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: shopping_carts; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: signup_hints; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: subjects; Type: TABLE DATA; Schema: public; Owner: postgres
--

INSERT INTO public.subjects VALUES ('arranging', 'Arranging');
INSERT INTO public.subjects VALUES ('music-business', 'Music Business');
INSERT INTO public.subjects VALUES ('music-theory', 'Music Theory');
INSERT INTO public.subjects VALUES ('composing', 'Composition');
INSERT INTO public.subjects VALUES ('recording', 'Recording & Production');
INSERT INTO public.subjects VALUES ('site-reading', 'Sight Reading');
INSERT INTO public.subjects VALUES ('film-scoring', 'Film Scoring');
INSERT INTO public.subjects VALUES ('video-game-scoring', 'Video Game Scoring');
INSERT INTO public.subjects VALUES ('ear-training', 'Ear Training');
INSERT INTO public.subjects VALUES ('harmony', 'Harmony');
INSERT INTO public.subjects VALUES ('music-therapy', 'Music Therapy');
INSERT INTO public.subjects VALUES ('songwriting', 'Songwriting');
INSERT INTO public.subjects VALUES ('conducting', 'Conducting');
INSERT INTO public.subjects VALUES ('instrument-repair', 'Instrument Repair');
INSERT INTO public.subjects VALUES ('improvisation', 'Improvisation');
INSERT INTO public.subjects VALUES ('pro-tools', 'Pro Tools');
INSERT INTO public.subjects VALUES ('ableton-live', 'Ableton Live');
INSERT INTO public.subjects VALUES ('fl-studio', 'FL Studio');
INSERT INTO public.subjects VALUES ('garageband', 'GarageBand');
INSERT INTO public.subjects VALUES ('apple-logic-pro', 'Apple Logic Pro');
INSERT INTO public.subjects VALUES ('presonus-studio-one', 'PreSonus Studio One');
INSERT INTO public.subjects VALUES ('reaper', 'Reaper');
INSERT INTO public.subjects VALUES ('cubase', 'Cubase');
INSERT INTO public.subjects VALUES ('sonar', 'Sonar');
INSERT INTO public.subjects VALUES ('reason', 'Reason');
INSERT INTO public.subjects VALUES ('amplitube', 'AmpliTube');
INSERT INTO public.subjects VALUES ('line-6-pod', 'Line 6 Pod');
INSERT INTO public.subjects VALUES ('guitar-ring', 'Guitar Rig');


--
-- Data for Name: teacher_payments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teacher_distributions; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teachers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teacher_experiences; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teacher_intents; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teachers_genres; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teachers_instruments; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teachers_languages; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: teachers_subjects; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: test_drive_package_choice_teachers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: test_drive_package_teachers; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: text_messages; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: tracks; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Name: tracks_next_tracker_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.tracks_next_tracker_seq', 1, false);


--
-- Data for Name: user_authorizations; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: user_blacklists; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: user_events; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: user_whitelists; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- Data for Name: video_sources; Type: TABLE DATA; Schema: public; Owner: postgres
--



--
-- PostgreSQL database dump complete
--




SET search_path TO "$user",public;

