* VRFS-982 and VRFS-1003 - making every table that's directly related to music_session be UNLOGGED

This commit is contained in:
Seth Call 2014-01-19 05:17:30 +00:00
parent 5c8e315ee5
commit dea36d897f
6 changed files with 145 additions and 9 deletions

View File

@ -19,7 +19,7 @@ rm -rf $TARGET
mkdir -p $PG_BUILD_OUT
mkdir -p $PG_RUBY_PACKAGE_OUT
bundle update
#bundle update
echo "building migrations"
bundle exec pg_migrate build --source . --out $PG_BUILD_OUT --test --verbose

View File

@ -88,4 +88,5 @@ icecast.sql
home_page_promos.sql
mix_job_watch.sql
music_session_constraints.sql
mixes_drop_manifest_add_retry.sql
mixes_drop_manifest_add_retry.sql
integrate_icecast_into_sessions.sql

View File

@ -0,0 +1,129 @@
-- this manifest update makes every table associated with music_sessions UNLOGGED
-- tables to mark UNLOGGED
-- connections, fan_invitations, invitations, genres_music_sessions, join_requests, tracks, music_sessions
-- tables to just get rid of
-- session_plays
-- breaking foreign keys for tables
-- connections: user_id
-- fan_invitations: receiver_id, sender_id
-- music_session: user_id, band_id, claimed_recording_id, claimed_recording_initiator_id
-- genres_music_sessions: genre_id
-- invitations: sender_id, receiver_id
-- fan_invitations: user_id
-- notifications: invitation_id, join_request_id, session_id
DROP TABLE sessions_plays;
-- divorce notifications from UNLOGGED tables
-- NOTIFICATIONS
----------------
-- "notifications_session_id_fkey" FOREIGN KEY (session_id) REFERENCES music_sessions(id) ON DELETE CASCADE
ALTER TABLE notifications DROP CONSTRAINT notifications_session_id_fkey;
-- "notifications_join_request_id_fkey" FOREIGN KEY (join_request_id) REFERENCES join_requests(id) ON DELETE CASCADE
ALTER TABLE notifications DROP CONSTRAINT notifications_join_request_id_fkey;
-- "notifications_invitation_id_fkey" FOREIGN KEY (invitation_id) REFERENCES invitations(id) ON DELETE CASCADE
ALTER TABLE notifications DROP CONSTRAINT notifications_invitation_id_fkey;
-- FAN_INVITATIONS
------------------
DROP TABLE fan_invitations;
DROP TABLE invitations;
DROP TABLE join_requests;
DROP TABLE genres_music_sessions;
DROP TABLE tracks;
DROP TABLE connections;
DROP TABLE music_sessions;
-- MUSIC_SESSIONS
-----------------
CREATE UNLOGGED TABLE music_sessions (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
description VARCHAR(8000),
user_id VARCHAR(64) NOT NULL,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL,
musician_access BOOLEAN NOT NULL,
band_id VARCHAR(64),
approval_required BOOLEAN NOT NULL,
fan_access BOOLEAN NOT NULL,
fan_chat BOOLEAN NOT NULL,
claimed_recording_id VARCHAR(64),
claimed_recording_initiator_id VARCHAR(64)
);
-- CONNECTIONS
--------------
CREATE UNLOGGED TABLE connections (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
user_id VARCHAR(64),
client_id VARCHAR(64) UNIQUE 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 VARCHAR(64),
ip_address VARCHAR(64),
as_musician BOOLEAN,
aasm_state VARCHAR(64) DEFAULT 'idle'::VARCHAR NOT NULL
);
ALTER TABLE ONLY connections ADD CONSTRAINT connections_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES music_sessions(id) ON DELETE SET NULL;
-- GENRES_MUSIC_SESSIONS
------------------------
CREATE UNLOGGED TABLE genres_music_sessions (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
genre_id VARCHAR(64),
music_session_id VARCHAR(64)
);
ALTER TABLE ONLY genres_music_sessions ADD CONSTRAINT genres_music_sessions_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES music_sessions(id) ON DELETE CASCADE;
CREATE UNLOGGED TABLE fan_invitations (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
sender_id VARCHAR(64),
receiver_id VARCHAR(64),
music_session_id VARCHAR(64),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL
);
ALTER TABLE ONLY fan_invitations ADD CONSTRAINT fan_invitations_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES music_sessions(id) ON DELETE CASCADE;
CREATE UNLOGGED TABLE join_requests (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
user_id VARCHAR(64),
music_session_id VARCHAR(64),
text VARCHAR(2000),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL
);
ALTER TABLE ONLY join_requests ADD CONSTRAINT user_music_session_uniqkey UNIQUE (user_id, music_session_id);
ALTER TABLE ONLY join_requests ADD CONSTRAINT join_requests_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES music_sessions(id) ON DELETE CASCADE;
-- INVITATIONS
--------------
CREATE UNLOGGED TABLE invitations (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
sender_id VARCHAR(64),
receiver_id VARCHAR(64),
music_session_id VARCHAR(64),
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() NOT NULL,
join_request_id VARCHAR(64)
);
ALTER TABLE ONLY invitations ADD CONSTRAINT invitations_uniqkey UNIQUE (sender_id, receiver_id, music_session_id);
ALTER TABLE ONLY invitations ADD CONSTRAINT invitations_join_request_id_fkey FOREIGN KEY (join_request_id) REFERENCES join_requests(id) ON DELETE CASCADE;
ALTER TABLE ONLY invitations ADD CONSTRAINT invitations_music_session_id_fkey FOREIGN KEY (music_session_id) REFERENCES music_sessions(id) ON DELETE CASCADE;
-- TRACKS
---------
CREATE UNLOGGED TABLE tracks (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL,
connection_id VARCHAR(64),
instrument_id VARCHAR(64),
sound VARCHAR(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 VARCHAR(64) NOT NULL
);
ALTER TABLE ONLY tracks ADD CONSTRAINT connections_tracks_connection_id_fkey FOREIGN KEY (connection_id) REFERENCES connections(id) ON DELETE CASCADE;

View File

@ -558,7 +558,7 @@ module JamRuby
# create a source up requested message to send to clients in a session,
# so that one of the clients will start sending source audio to icecast
def source_up_requested (session_id, host, port, mount, source_user, source_pass)
def source_up_requested (session_id, host, port, mount, source_user, source_pass)
source_up_requested = Jampb::SourceUpRequested.new(
host: host,
port: port,

View File

@ -760,12 +760,23 @@ module JamRuby
@@mq_router.server_publish_to_session(music_session, msg, sender = {:client_id => client_id})
end
def send_download_available(user_id)
msg = @@message_factory.download_available
@@mq_router.publish_to_user(user_id, msg)
end
def send_source_up_requested(music_session, host, port, mount, source_user, source_pass)
msg = @@message_factory.source_up_requested(music_session.id, host, port, mount, source_user, source_pass)
@@mg_router.server_publish_to_session(music_session, msg)
end
def send_source_down_requested(music_session, mount)
msg = @@message_factory.source_down_requested(music_session.id, mount)
@@mq_router.server_publish_to_session(music_session, msg)
end
end
end
end

View File

@ -45,10 +45,6 @@ describe ConnectionManager do
end
end
it "can't create bogus user_id" do
expect { @connman.create_connection("aeonuthaoentuh", "client_id", "1.1.1.1") }.to raise_error(PG::Error)
end
it "can't create two client_ids of same value" do
client_id = "client_id1"
@ -428,7 +424,6 @@ describe ConnectionManager do
@connman.delete_connection(client_id)
assert_num_connections(client_id, 0)
end
end