summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r--Bugzilla/DB/Schema.pm6
-rw-r--r--Bugzilla/DB/Schema/Sqlite.pm17
-rw-r--r--Bugzilla/DB/Sqlite.pm45
3 files changed, 65 insertions, 3 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index fb62965e3..33527c367 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -1000,7 +1000,7 @@ use constant ABSTRACT_SCHEMA => {
],
},
- tags => {
+ tag => {
FIELDS => [
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
name => {TYPE => 'varchar(64)', NOTNULL => 1},
@@ -1010,7 +1010,7 @@ use constant ABSTRACT_SCHEMA => {
DELETE => 'CASCADE'}},
],
INDEXES => [
- tags_user_id_idx => {FIELDS => [qw(user_id name)], TYPE => 'UNIQUE'},
+ tag_user_id_idx => {FIELDS => [qw(user_id name)], TYPE => 'UNIQUE'},
],
},
@@ -1021,7 +1021,7 @@ use constant ABSTRACT_SCHEMA => {
COLUMN => 'bug_id',
DELETE => 'CASCADE'}},
tag_id => {TYPE => 'INT3', NOTNULL => 1,
- REFERENCES => {TABLE => 'tags',
+ REFERENCES => {TABLE => 'tag',
COLUMN => 'id',
DELETE => 'CASCADE'}},
],
diff --git a/Bugzilla/DB/Schema/Sqlite.pm b/Bugzilla/DB/Schema/Sqlite.pm
index 4730c4f9f..aad1f17bc 100644
--- a/Bugzilla/DB/Schema/Sqlite.pm
+++ b/Bugzilla/DB/Schema/Sqlite.pm
@@ -162,6 +162,23 @@ sub get_create_database_sql {
die "Reached an unreachable point";
}
+sub _get_create_table_ddl {
+ my $self = shift;
+ my ($table) = @_;
+ my $ddl = $self->SUPER::_get_create_table_ddl(@_);
+
+ # TheSchwartz uses its own driver to access its tables, meaning
+ # that it doesn't understand "COLLATE bugzilla" and in fact
+ # SQLite throws an error when TheSchwartz tries to access its
+ # own tables, if COLLATE bugzilla is on them. We don't have
+ # to fix this elsewhere currently, because we only create
+ # TheSchwartz's tables, we never modify them.
+ if ($table =~ /^ts_/) {
+ $ddl =~ s/ COLLATE bugzilla//g;
+ }
+ return $ddl;
+}
+
sub get_type_ddl {
my $self = shift;
my $def = dclone($_[0]);
diff --git a/Bugzilla/DB/Sqlite.pm b/Bugzilla/DB/Sqlite.pm
index e40a264f0..fb6aaba97 100644
--- a/Bugzilla/DB/Sqlite.pm
+++ b/Bugzilla/DB/Sqlite.pm
@@ -25,6 +25,7 @@ use base qw(Bugzilla::DB);
use Bugzilla::Constants;
use Bugzilla::Error;
+use Bugzilla::Install::Util qw(install_string);
use DateTime;
use POSIX ();
@@ -39,6 +40,10 @@ use constant ISOLATION_LEVEL => undef;
use constant WORD_START => '(?:^|\W)';
use constant WORD_END => '(?:$|\W)';
+# For some reason, dropping the related FKs causes the index to
+# disappear early, which causes all sorts of problems.
+use constant INDEX_DROPS_REQUIRE_FK_DROPS => 0;
+
####################################
# Functions Added To SQLite Itself #
####################################
@@ -242,6 +247,46 @@ sub sql_string_until {
# bz_ methods #
###############
+sub bz_setup_database {
+ my $self = shift;
+ $self->SUPER::bz_setup_database(@_);
+
+ # If we created TheSchwartz tables with COLLATE bugzilla (during the
+ # 4.1.x development series) re-create them without it.
+ my @tables = $self->bz_table_list();
+ my @ts_tables = grep { /^ts_/ } @tables;
+ my $drop_ok;
+ foreach my $table (@ts_tables) {
+ my $create_table =
+ $self->_bz_real_schema->_sqlite_create_table($table);
+ if ($create_table =~ /COLLATE bugzilla/) {
+ if (!$drop_ok) {
+ _sqlite_jobqueue_drop_message();
+ $drop_ok = 1;
+ }
+ $self->bz_drop_table($table);
+ $self->bz_add_table($table);
+ }
+ }
+}
+
+sub _sqlite_jobqueue_drop_message {
+ # This is not translated because this situation will only happen if
+ # you are updating from a 4.1.x development version of Bugzilla using
+ # SQLite, and we don't want to maintain this string in strings.txt.pl
+ # forever for just this one uncommon circumstance.
+ print <<END;
+WARNING: We have to re-create all the database tables used by jobqueue.pl.
+If there are any pending jobs in the database (that is, emails that
+haven't been sent), they will be deleted.
+
+END
+ unless (Bugzilla->installation_answers->{NO_PAUSE}) {
+ print install_string('enter_or_ctrl_c');
+ getc;
+ }
+}
+
# XXX This needs to be implemented.
sub bz_explain { }