-- Convert schema '/home/sergio/LasTres/script/../dbicdh/_source/deploy/1/001-auto.yml' to '/home/sergio/LasTres/script/../dbicdh/_source/deploy/2/001-auto.yml':;

;
BEGIN;

;
ALTER TABLE player_pjs DROP CONSTRAINT player_pjs_fk_owner;

;
ALTER TABLE player_pjs DROP CONSTRAINT player_pjs_fk_stats;

;
DROP INDEX player_pjs_idx_stats;

;
ALTER TABLE player_pjs DROP COLUMN stats;

;
ALTER TABLE player_pjs ADD COLUMN born_stats uuid NOT NULL;

;
ALTER TABLE player_pjs ADD COLUMN training_stats uuid NOT NULL;

;
CREATE INDEX player_pjs_idx_born_stats on player_pjs (born_stats);

;
CREATE INDEX player_pjs_idx_training_stats on player_pjs (training_stats);

;
ALTER TABLE player_pjs ADD CONSTRAINT player_pjs_fk_born_stats FOREIGN KEY (born_stats)
  REFERENCES stats (uuid) DEFERRABLE;

;
ALTER TABLE player_pjs ADD CONSTRAINT player_pjs_fk_owner FOREIGN KEY (owner)
  REFERENCES players (uuid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

;
ALTER TABLE player_pjs ADD CONSTRAINT player_pjs_fk_training_stats FOREIGN KEY (training_stats)
  REFERENCES stats (uuid) DEFERRABLE;

;
ALTER TABLE stats DROP COLUMN charisma;

;

COMMIT;

