Skip to content

Commit

Permalink
Upgrade script fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Jan 19, 2006
1 parent dc14597 commit cb9eae8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
6 changes: 3 additions & 3 deletions inst/upgrade/1.10.0/rm_old_sort_prefs.pl
Expand Up @@ -4,13 +4,13 @@
use File::Spec::Functions qw(catdir updir);
use FindBin;
use lib catdir $FindBin::Bin, updir, 'lib';
use Bric::Config qw(MASON_COMP_ROOT);
use Bric::Util::Trans::FS;
use bric_upgrade qw(:all);

do_sql
q{DELETE from pref_opt WHERE value in ('id', 'category_name')},
q{DELETE from pref_opt WHERE value IN ('id', 'category_name')},
q{UPDATE pref_opt SET description = 'Cover Date/Deploy Date'
WHERE value = 'cover_date'},
q{UPDATE pref_opt SET description = 'Document Type/Output Channel'
WHERE value = 'element'},
;

44 changes: 42 additions & 2 deletions inst/upgrade/1.10.0/update_publish_status_check.pl
Expand Up @@ -7,9 +7,49 @@
use bric_upgrade qw(:all);

for my $thing (qw(story media)) {
do_sql
qq{ALTER TABLE $thing DROP CONSTRAINT ck_$thing\__publish_status},
if (test_constraint $thing, "ck_$thing\__publish_status") {
do_sql qq{ALTER TABLE $thing DROP CONSTRAINT ck_$thing\__publish_status};

} else {
do_sql
qq{UPDATE $thing
SET publish_status = '1'
WHERE published_version IS NOT NULL
AND publish_status = '0'
},

# We have no idea what version was actually published, so
# current_version is the best we can do. :-(
qq{UPDATE $thing
SET published_version = current_version
WHERE published_version IS NULL
AND publish_status = '1'
},

# We don't know if it has been published since the first
# publish date, so just go with that.
qq{UPDATE $thing
SET publish_date = first_publish_date
WHERE publish_date IS NULL
AND first_publish_date IS NOT NULL
},

# And the reverse.
qq{UPDATE $thing
SET first_publish_date = publish_date
WHERE first_publish_date IS NULL
AND publish_date IS NOT NULL
},

# Remove the publish_status when there are no publish dates.
qq{UPDATE $thing
SET publish_status = '0'
WHERE publish_date IS NULL
},
;

}
do_sql
qq{ALTER TABLE $thing
ADD CONSTRAINT ck_$thing\__publish_status CHECK (
(
Expand Down

0 comments on commit cb9eae8

Please sign in to comment.