Commit 5e78b7a0 authored by Leigh Stoller's avatar Leigh Stoller

Minor change to how archive_tags table is structured.

parent 8f826f70
......@@ -36,9 +36,10 @@ CREATE TABLE archive_tags (
idx int(10) unsigned NOT NULL auto_increment,
tag varchar(64) NOT NULL default '',
archive_idx int(10) unsigned NOT NULL default '0',
view varchar(64) NOT NULL default '',
date_created int(10) unsigned NOT NULL default '0',
PRIMARY KEY (idx),
UNIQUE KEY tag (tag,archive_idx)
UNIQUE KEY tag (tag,archive_idx,view)
) TYPE=MyISAM;
--
......
......@@ -3076,4 +3076,24 @@ last_net_act,last_cpu_act,last_ext_act);
alter table archives add date_archived int(10) unsigned \
NOT NULL default '0';
4.28: Some changes to the archive_tags table, for support of forking
an archive.
CREATE TABLE archive_tags_new (
idx int(10) unsigned NOT NULL auto_increment,
tag varchar(64) NOT NULL default '',
archive_idx int(10) unsigned NOT NULL default '0',
view varchar(64) NOT NULL default '',
date_created int(10) unsigned NOT NULL default '0',
PRIMARY KEY (idx),
UNIQUE KEY tag (tag,archive_idx,view)
) TYPE=MyISAM;
insert into archive_tags_new (idx,tag,archive_idx,view,date_created) \
select distinct NULL,t.tag,t.archive_idx,v.view,t.date_created \
from archive_tags as t left join archive_views as v on \
v.archive_idx=t.archive_idx;
rename table archive_tags TO archive_tags_old, \
archive_tags_new TO archive_tags;
......@@ -197,7 +197,7 @@ sub ArchiveCreate(;$$$)
" date_created=UNIX_TIMESTAMP(now())") or goto bad;
# Now enter an initial tag for the tree. Nothing actually gets tagged.
DBQueryWarn("insert into archive_tags set idx=NULL, ".
DBQueryWarn("insert into archive_tags set idx=NULL, view='$view', ".
" tag='$tag', archive_idx='$idx', ".
" date_created=UNIX_TIMESTAMP(now())") or goto bad;
......@@ -416,7 +416,7 @@ sub ArchiveSavePoint($;$$$)
# And record the new tag.
#
DBQueryWarn("insert into archive_tags set idx=NULL, ".
" tag='$savetag', ".
" tag='$savetag', view='$view', ".
" archive_idx='$archive_idx', ".
" date_created=UNIX_TIMESTAMP(now())") or goto bad;
......@@ -515,7 +515,7 @@ sub ArchiveCommit($;$$$)
#
my $query_result =
DBQueryWarn("select tag from archive_tags ".
"where archive_idx='$archive_idx' ".
"where archive_idx='$archive_idx' and view='$view' ".
"order by idx desc limit 1");
goto bad
if (!$query_result || !$query_result->numrows);
......@@ -593,7 +593,7 @@ sub ArchiveCommit($;$$$)
== 0 or goto bad;
DBQueryWarn("insert into archive_tags set idx=NULL, ".
" tag='$newtag', ".
" tag='$newtag', view='$view', ".
" archive_idx='$archive_idx', ".
" date_created=UNIX_TIMESTAMP(now())")
or goto bad;
......@@ -769,6 +769,7 @@ sub ArchiveFork($$;$$$)
# Now enter an initial tag for the new view. Nothing actually gets tagged.
DBQueryWarn("insert into archive_tags set idx=NULL, ".
" tag='$newtag', archive_idx='$archive_idx', ".
" view='$newview', ".
" date_created=UNIX_TIMESTAMP(now())") or goto bad;
okay:
......@@ -1057,7 +1058,7 @@ sub GetArchiveCurrentTags($$$;$)
" from archive_views as v ".
"left join archive_tags as t on ".
" t.archive_idx=v.archive_idx and ".
" t.tag=v.current_tag ".
" t.tag=v.current_tag and t.view=v.view ".
"where v.archive_idx='$archive_idx' and ".
" v.view='$view'");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment