VRFS-1959 : change the primary key (id) to be a big int and to share the sequence used by mixes.id and recorded_tracks.id

Also modify references as necessary, both from other tables and various
code usages.
This commit is contained in:
Steven Miers 2014-12-06 19:55:59 -06:00
parent 207b7b9e20
commit 8634d4f726
5 changed files with 31 additions and 10 deletions

View File

@ -229,4 +229,4 @@ deletable_recordings.sql
jam_tracks.sql
shopping_carts.sql
recurly.sql
jam_track_rights_updates.sql
jam_track_updates.sql

View File

@ -1,7 +0,0 @@
ALTER TABLE jam_track_rights
DROP CONSTRAINT jam_track_rights_user_id_fkey,
DROP CONSTRAINT jam_track_rights_jam_track_id_fkey,
ADD CONSTRAINT jam_track_rights_user_id_fkey FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
ADD CONSTRAINT jam_track_rights_jam_track_id_fkey FOREIGN KEY(jam_track_id) REFERENCES jam_tracks(id) ON DELETE CASCADE,
ADD COLUMN s3_url VARCHAR(2048);

View File

@ -0,0 +1,29 @@
-- Drop Jam Track Tracks constraints:
ALTER TABLE jam_track_tracks
DROP CONSTRAINT jam_track_tracks_jam_track_id_fkey;
-- Drop Jam Track Tracks constraints:
ALTER TABLE jam_track_rights
DROP CONSTRAINT jam_track_rights_user_id_fkey,
DROP CONSTRAINT jam_track_rights_jam_track_id_fkey;
-- Change Jam Tracks ID type to BIGINT so it can work like the other downloadable items:
ALTER TABLE jam_tracks
ALTER COLUMN id DROP DEFAULT,
ALTER COLUMN id TYPE BIGINT USING nextval('tracks_next_tracker_seq'),
ALTER COLUMN id SET DEFAULT nextval('tracks_next_tracker_seq');
-- Change referencing ID type and re-add constraints:
ALTER TABLE jam_track_tracks
ALTER COLUMN jam_track_id TYPE BIGINT USING 0,
ALTER COLUMN jam_track_id SET NOT NULL,
ADD CONSTRAINT jam_track_tracks_jam_track_id_fkey FOREIGN KEY(jam_track_id) REFERENCES jam_tracks(id) ON DELETE CASCADE;
-- Change referencing ID type and re-add constraints. Also
-- add S3 URL for user-specific downloads:
ALTER TABLE jam_track_rights
ADD COLUMN s3_url VARCHAR(2048),
ALTER COLUMN jam_track_id TYPE BIGINT USING 0,
ALTER COLUMN jam_track_id SET NOT NULL,
ADD CONSTRAINT jam_track_rights_user_id_fkey FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
ADD CONSTRAINT jam_track_rights_jam_track_id_fkey FOREIGN KEY(jam_track_id) REFERENCES jam_tracks(id) ON DELETE CASCADE;

View File

@ -156,7 +156,6 @@
e.preventDefault();
var params = {id: $(e.target).attr("data-jamtrack-id")};
rest.addJamtrackToShoppingCart(params)
.done(function(response) {
context.location = "/client#/shoppingCart";

View File

@ -7,7 +7,7 @@ node :genres do |item|
end
node :added_cart do |item|
current_user.shopping_carts.map(&:cart_id).include? item.id
current_user.shopping_carts.where("cart_id='?'",item.id).count != 0
end
child(:jam_track_tracks => :tracks) {