
joan.moreau at m4x
Feb 22, 2009, 5:09 AM
Post #1 of 2
(562 views)
Permalink
|
|
fix_foreign_keys (was: Segfault in the git)
|
|
My emails are obviously not gettingthrough. I re-send again. Please confirm you receive this email -------- Original Message -------- diff --git a/INSTALL b/INSTALL index c457b3a..d3c5b40 100644 --- a/INSTALL +++ b/INSTALL @@ -1,217 +1,237 @@ -/* - (c) 2000-2004 IC&S, The Netherlands - (c) 2004-2007 NFG, The Netherlands - - -FIXME: this information is somewhat outdated -TODO: -tell more about where to find what library -add information about utf8 setups for mysql users -add information about advanced setups with connection pools - -*/ - -DBMAIL Installation -=================== - -What do you need? - -- A working database, one of the following: - - MySQL 4.1.3 or higher with InnoDB. - - PostgreSQL 7.4 or higher. - - SQLite 3 or higher. -- A working SMTP server (such as Postfix, Exim, QMail or Sendmail). -- The DBMail source (www.dbmail.org). -- GNU Make. On Linux systems, your standard 'make' program is GNU Make. On *BSD - systems, make sure you install and use 'gmake'. -- Development files (libs, scripts and include files) for your database server. - These will probably be provided by separate packages. -- Glib (>= 2.8) development headers and libraries. -- Gmime (>= 2.1.18) development headers and libraries. -- libSieve for Sieve support (libsieve.sf.net). -- Any standard libldap for LDAP support (only tested with OpenLDAP, however). -- mhash -- libzdb (http://www.tildeslash.com/libzdb/) -- libevent - - -1. Setup a database - - MySQL setup - ----------- - - First you'll need to create the DBMail database in MYSQL. You can do - this by issuing the following command. This step is only necessary when - you do not have a database for DBMail yet. Note that you will be - prompted for the MySQL root password. - - mysqladmin create dbmail -u root -p - - This creates a database with the name "dbmail". Now you have to give - a non-root user access to this database. Start the MySQL command-line - client as root: - - mysql -u root -p - - and enter the following command: - - GRANT ALL ON dbmail.* to dbmail [at] localhos identified by '<pass>' - - Where <pass> should be replaced with the password you want for - the dbmail user. After this step, the database is ready to be - used by the dbmail user. The next step is the creation of the - database tables used by DBMail. Log out of the MySQL client and run - the following command from the command line. You will have to - enter the password you set in the previous step. - - mysql -u dbmail dbmail -p < sql/mysql/create_tables.mysql - - After this, the DBMAIL tables will have been created and we can go - on to the compilation and installation of DBMail itself. - - PostgreSQL setup - ---------------- - - First you need to create the PostgreSQL user dbmail is going to use. - This is done by. Note that this command can only be performed by - user postgres or another PostgreSQL user with the privileges to - create users and and databases. - - createuser -U postgres dbmail - - Off course you can use an other username than dbmail, simply replace - it. You can set a password for the user by doing a: - - ALTER USER dbmail WITH PASSWORD '<password>'; - - In a PostgreSQL console, with <password> replaced by the actual - password you want to use. After doing this you should create the - database for dbmail: - - createdb -E utf8 -U postgres -O dbmail dbmail - - The first dbmail is the user you just created, the second the name of - the database. Of course you can use an other database name. After - setting up the user and database it's time to create the tables, do a: - - psql -U dbmail dbmail < sql/postgresql/create_tables.pgsql - - Don't forget to start postgresql with the -i option, so it accepts - TCP/IP connections. - - SQLite setup - ------------ - - Dbmail will automatically create the database specified in dbmail.conf. - All you need to do is make sure that the directory which will contain - the database file exists, and is writable for the dbmail user. - -2. Set the database settings - - Copy the dbmail.conf file to /etc - Edit the dbmail.conf file and set everything in there - to your likings. - - Make sure to set your database name, user and host are configured - in dbmail.conf. Other options in the configuration file are - documented there. - -3. Run configure & make - Run the configure script. This script uses pg_config or mysql_config - (depending on --with-mysql or --with-pgsql) to detect where the - libraries and include files for these databases are. - - e.g. when working with PostgreSQL, this is the configure command: - - ./configure --with-pgsql - - After running configure, 'make all' will build the executables. - - Running 'make install' will install the executables in /usr/local/sbin - -4. Create users in the dbmail system - - Next you will need to create some users into the dbmail mailing system. - Currently this can be done in two ways. One way is using the - dbmail-users utility. The other way is doing it in the database - itself. To do it using the dbmail-users utility and do the following: - - dbmail-users -a <username> -w <password> -g <clientid> -m <maxmail> [-s aliases] - - clientid can be left 0 (this is if you want certain mail administrators - administer specific groups of mail users). maxmail is the maximum - number of bytes this user may have in his/her mailboxes. 0 is - unlimited. Add K or M for kilobytes and megabytes. Aliases are a - number of aliases for this user. @domain are domain aliases. - A user always needs to have at least one alias to receive mail, unless - the users username is something like foo [at] bar, where bar.org is - a domain the mail server delivers to. - - example: - ./dbmail-users -a john -w secret -g 0 -m 25M -s john [at] dude,john [at] dude,@net.com - - This will create a user john, with a password secret. It will set - john's mail limit 25 Mb and all mail for john [at] dude, john [at] dude - and @net.com will be sent to john. The @net.com is a fallback alias. - This means that all mail that cannot be delivered to an existing alias - for a @net.com address will sent to john. - -5. Configure your MTA - - There are two ways to connect your MTA to DBMail. The MTA can start a - dbmail-deliver process and pipe SMTP commands and messages to it, or it - can use LMTP (Local Mail Transport Protocol) to deliver via - dbmail-lmtpd. LMTP is the preferred solution because it offers more - robust error handling and because it is a daemon, high traffic servers - will have reduced delays which would be incurred starting up a - dbmail-deliver process for each message. - - The specifics of delivering to DBMail from your MTA can be found in the - README.<MTA Name> files. Currently there is documentation for Postfix, - Exim and QMail. Other setup information can also be found on the - project wiki, at http://www.dbmail.org/dokuwiki - - If you use a different kind of MTA that we do not have documentation - for: The dbmail injector program, dbmail-deliver, can receive information - in two ways. Either through raw mail (for example, delivered by - procmail) using the -n option or from a MTA with recipients in the - command line using the -d option. Be careful, the -n option is not - fully tested and may behave unexpected. If possible use the -d option. - - Setup for LMTP should be straightforward if your MTA supports it. - -6. Setting up the maintenance run - - The dbmail daemons and the smtp injector itself will never actually - delete mail from the database. The only program that will do this is - the dbmail-util program. This program will also check the integrity of - the dbmail database and, if necessary, fix it. The dbmail-util program - will first delete all messages that are set for final deletion. After - that it will set all messages that have the delete status set to status - final deletion. This way dbmail always has a backup based upon the - interval difference between maintenance jobs. We recommend running the - dbmail-util program in a daily interval from cron: - - 0 3 * * * /usr/local/sbin/dbmail-util -ay &>/dev/null - -7. Starting the servers - - If you want users to be able to retrieve email via IMAP or POP3, run - dbmail-imapd and/or dbmail-pop3d. If you are delivering email via - LMTP, run dbmail-lmtpd (you should start LMTP before your MTA!). - -8. Problems - -------- - For problems you can subscribe to the dbmail mailing list: - http://mailman.fastxs.nl/mailman/listinfo/dbmail - - Please also check the mailing list archives, - the wiki at: http://www.dbmail.org/dokuwiki - and the bugs at: http://www.dbmail.org/mantis - - Please note that DBMail logs a lot of relevant data to the mail log - (often located at /var/log/maillog or /var/log/mail.log). This can - help you often if something is not working, e.g. if there's no - connection to the database. - +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. diff --git a/sql/mysql/fix_foreign_keys.mysql b/sql/mysql/fix_foreign_keys.mysql index bcb506d..efdb133 100644 --- a/sql/mysql/fix_foreign_keys.mysql +++ b/sql/mysql/fix_foreign_keys.mysql @@ -42,8 +42,9 @@ SET FOREIGN_KEY_CHECKS=0; alter table dbmail_mailboxes drop foreign key owner_idnr_fk; alter table dbmail_mailboxes drop foreign key dbmail_mailboxes_ibfk; alter table dbmail_mailboxes drop foreign key dbmail_mailboxes_ibfk_1; -alter table dbmail_mailboxes add FOREIGN KEY owner_idnr_fk (owner_idnr) - REFERENCES dbmail_users (user_idnr) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_mailboxes drop foreign key dbmail_mailboxes_ibfk_2; +alter table dbmail_mailboxes add CONSTRAINT dbmail_mailboxes_ibfk_1 + FOREIGN KEY (`owner_idnr`) REFERENCES `dbmail_users` (`user_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_subscription drop foreign key user_id_fk; @@ -51,10 +52,10 @@ alter table dbmail_subscription drop foreign key mailbox_id_fk; alter table dbmail_subscription drop foreign key dbmail_subscription_ibfk_1; alter table dbmail_subscription drop foreign key dbmail_subscription_ibfk_2; alter table dbmail_subscription drop foreign key dbmail_subscription_ibfk_3; -alter table dbmail_subscription add FOREIGN KEY user_id_fk (user_id) - REFERENCES dbmail_users (user_idnr) ON DELETE CASCADE ON UPDATE CASCADE; -alter table dbmail_subscription add FOREIGN KEY mailbox_id_fk (mailbox_id) - REFERENCES dbmail_mailboxes (mailbox_idnr) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_subscription add CONSTRAINT dbmail_subscription_ibfk_1 + FOREIGN KEY (`user_id`) REFERENCES `dbmail_users` (`user_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_subscription add CONSTRAINT dbmail_subscription_ibfk_2 + FOREIGN KEY (`mailbox_id`) REFERENCES `dbmail_mailboxes` (`mailbox_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_acl drop foreign key user_id_fk; @@ -62,10 +63,10 @@ alter table dbmail_acl drop foreign key mailbox_id_fk; alter table dbmail_acl drop foreign key dbmail_acl_ibfk_1; alter table dbmail_acl drop foreign key dbmail_acl_ibfk_2; alter table dbmail_acl drop foreign key dbmail_acl_ibfk_3; -alter table dbmail_acl add FOREIGN KEY user_id_fk (user_id) - REFERENCES dbmail_users (user_idnr) ON DELETE CASCADE ON UPDATE CASCADE; -alter table dbmail_acl add FOREIGN KEY mailbox_id_fk (mailbox_id) - REFERENCES dbmail_mailboxes (mailbox_idnr) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_acl add CONSTRAINT dbmail_acl_ibfk_1 + FOREIGN KEY (`user_id`) REFERENCES `dbmail_users` (`user_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_acl add CONSTRAINT dbmail_acl_ibfk_2 + FOREIGN KEY (`mailbox_id`) REFERENCES `dbmail_mailboxes` (`mailbox_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_messages drop foreign key physmessage_id_fk; @@ -73,174 +74,96 @@ alter table dbmail_messages drop foreign key mailbox_idnr_fk; alter table dbmail_messages drop foreign key dbmail_messages_ibfk_1; alter table dbmail_messages drop foreign key dbmail_messages_ibfk_2; alter table dbmail_messages drop foreign key dbmail_messages_ibfk_3; -alter table dbmail_messages add FOREIGN KEY physmessage_id_fk (physmessage_id) - REFERENCES dbmail_physmessage (id) ON DELETE CASCADE ON UPDATE CASCADE; -alter table dbmail_messages add FOREIGN KEY mailbox_idnr_fk (mailbox_idnr) - REFERENCES dbmail_mailboxes (mailbox_idnr) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_messages add CONSTRAINT dbmail_messages_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_messages add CONSTRAINT dbmail_messages_ibfk_2 + FOREIGN KEY (`mailbox_idnr`) REFERENCES `dbmail_mailboxes` (`mailbox_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_messageblks drop foreign key physmessage_id_fk; alter table dbmail_messageblks drop foreign key dbmail_messageblks_ibfk_1; alter table dbmail_messageblks drop foreign key dbmail_messageblks_ibfk_2; -alter table dbmail_messageblks add FOREIGN KEY physmessage_id_fk (physmessage_id) - REFERENCES dbmail_physmessage (id) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_messageblks add CONSTRAINT dbmail_messageblks_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_auto_notifications drop foreign key physmessage_id_fk; alter table dbmail_auto_notifications drop foreign key dbmail_auto_notifications_ibfk_1; alter table dbmail_auto_notifications drop foreign key dbmail_auto_notifications_ibfk_2; -alter table dbmail_auto_notifications add FOREIGN KEY user_idnr_fk (user_idnr) - REFERENCES dbmail_users (user_idnr) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_auto_notifications add CONSTRAINT dbmail_messageblks_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_auto_replies drop foreign key physmessage_id_fk; alter table dbmail_auto_replies drop foreign key dbmail_auto_replies_ibfk_1; alter table dbmail_auto_replies drop foreign key dbmail_auto_replies_ibfk_2; -alter table dbmail_auto_replies add FOREIGN KEY user_idnr_fk (user_idnr) - REFERENCES dbmail_users (user_idnr) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_auto_replies add CONSTRAINT dbmail_auto_replies_ibfk_1 + FOREIGN KEY (`user_idnr`) REFERENCES `dbmail_users` (`user_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; alter table dbmail_sievescripts drop foreign key physmessage_id_fk; alter table dbmail_sievescripts drop foreign key dbmail_sievescripts_ibfk_1; alter table dbmail_sievescripts drop foreign key dbmail_sievescripts_ibfk_2; -alter table dbmail_sievescripts add FOREIGN KEY owner_idnr_fk (owner_idnr) - REFERENCES dbmail_users (user_idnr) ON DELETE CASCADE ON UPDATE CASCADE; - - -DROP TABLE IF EXISTS dbmail_headervalue; -CREATE TABLE dbmail_headervalue ( - headername_id BIGINT NOT NULL, - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - headervalue TEXT NOT NULL, - PRIMARY KEY (id), - UNIQUE (physmessage_id, id), - UNIQUE (physmessage_id, headername_id, headervalue(255)), - INDEX (headername_id), - INDEX (physmessage_id), - FOREIGN KEY (headername_id) - REFERENCES dbmail_headername(id) ON UPDATE CASCADE ON DELETE CASCADE, - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -# Provide separate storage of commonly used headers - -# These fields will typically be preparsed as specified by -# http://www.ietf.org/internet-drafts/draft-ietf-imapext-sort-17.txt - -# Threading - -# support fast threading by breaking out In-Reply-To/References headers -# these fields contain zero or more Message-Id values that determine the message -# threading - -DROP TABLE IF EXISTS dbmail_subjectfield; -CREATE TABLE dbmail_subjectfield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - subjectfield VARCHAR(255) NOT NULL DEFAULT '', - PRIMARY KEY (id), - UNIQUE (physmessage_id, subjectfield), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -DROP TABLE IF EXISTS dbmail_datefield; -CREATE TABLE dbmail_datefield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - datefield DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00', - PRIMARY KEY (id), - UNIQUE (physmessage_id, datefield), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -DROP TABLE IF EXISTS dbmail_referencesfield; -CREATE TABLE dbmail_referencesfield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - referencesfield VARCHAR(255) NOT NULL DEFAULT '', - PRIMARY KEY (id), - UNIQUE (physmessage_id, referencesfield), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -# Searching and Sorting - -# support fast sorting by breaking out and preparsing the fields most commonly used -# in searching and sorting: Subject, From, To, Reply-To, Cc. - -DROP TABLE IF EXISTS dbmail_fromfield; -CREATE TABLE dbmail_fromfield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - fromname VARCHAR(100) NOT NULL DEFAULT '', - fromaddr VARCHAR(100) NOT NULL DEFAULT '', - PRIMARY KEY (id), - UNIQUE (physmessage_id, id), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -DROP TABLE IF EXISTS dbmail_tofield; -CREATE TABLE dbmail_tofield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - toname VARCHAR(100) NOT NULL DEFAULT '', - toaddr VARCHAR(100) NOT NULL DEFAULT '', - PRIMARY KEY (id), - UNIQUE (physmessage_id, id), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -DROP TABLE IF EXISTS dbmail_replytofield; -CREATE TABLE dbmail_replytofield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - replytoname VARCHAR(100) NOT NULL DEFAULT '', - replytoaddr VARCHAR(100) NOT NULL DEFAULT '', - PRIMARY KEY (id), - UNIQUE (physmessage_id, id), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -DROP TABLE IF EXISTS dbmail_ccfield; -CREATE TABLE dbmail_ccfield ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - ccname VARCHAR(100) NOT NULL DEFAULT '', - ccaddr VARCHAR(100) NOT NULL DEFAULT '', - PRIMARY KEY (id), - UNIQUE (physmessage_id, id), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB ; - -COMMIT; - -DROP TABLE IF EXISTS dbmail_envelope; -CREATE TABLE dbmail_envelope ( - physmessage_id BIGINT NOT NULL, - id BIGINT NOT NULL AUTO_INCREMENT, - envelope TEXT NOT NULL, - PRIMARY KEY (id), - UNIQUE (physmessage_id, id), - FOREIGN KEY (physmessage_id) - REFERENCES dbmail_physmessage(id) - ON UPDATE CASCADE ON DELETE CASCADE -) ENGINE=InnoDB; +alter table dbmail_sievescripts add CONSTRAINT dbmail_sievescripts_ibfk_1 + FOREIGN KEY (`owner_idnr`) REFERENCES `dbmail_users` (`user_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_header drop foreign key dbmail_header_ibfk_1; +alter table dbmail_header drop foreign key dbmail_header_ibfk_2; +alter table dbmail_header drop foreign key dbmail_header_ibfk_3; +alter table dbmail_header drop foreign key dbmail_header_ibfk_4; +alter table dbmail_header add CONSTRAINT `dbmail_header_ibfk_1` FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_header add CONSTRAINT `dbmail_header_ibfk_2` FOREIGN KEY (`headername_id`) REFERENCES `dbmail_headername` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; +alter table dbmail_header add CONSTRAINT `dbmail_header_ibfk_3` FOREIGN KEY (`headervalue_id`) REFERENCES `dbmail_headervalue` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_subjectfield drop foreign key dbmail_subjectfield_ibfk_1; +alter table dbmail_subjectfield drop foreign key dbmail_subjectfield_ibfk_2; +alter table dbmail_subjectfield add CONSTRAINT dbmail_subjectfield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_datefield drop foreign key dbmail_datefield_ibfk_1; +alter table dbmail_datefield drop foreign key dbmail_datefield_ibfk_2; +alter table dbmail_datefield add CONSTRAINT dbmail_datefield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_referencesfield drop foreign key dbmail_referencesfield_ibfk_1; +alter table dbmail_referencesfield drop foreign key dbmail_referencesfield_ibfk_2; +alter table dbmail_referencesfield add CONSTRAINT dbmail_referencesfield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_fromfield drop foreign key dbmail_fromfield_ibfk_1; +alter table dbmail_fromfield drop foreign key dbmail_fromfield_ibfk_2; +alter table dbmail_fromfield add CONSTRAINT dbmail_fromfield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_tofield drop foreign key dbmail_tofield_ibfk_1; +alter table dbmail_tofield drop foreign key dbmail_tofield_ibfk_2; +alter table dbmail_tofield add CONSTRAINT dbmail_tofield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_replytofield drop foreign key dbmail_replytofield_ibfk_1; +alter table dbmail_replytofield drop foreign key dbmail_replytofield_ibfk_2; +alter table dbmail_replytofield add CONSTRAINT dbmail_replytofield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_ccfield drop foreign key dbmail_datefield_ibfk_1; +alter table dbmail_ccfield drop foreign key dbmail_datefield_ibfk_2; +alter table dbmail_ccfield add CONSTRAINT dbmail_datefield_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + + +alter table dbmail_envelope drop foreign key dbmail_envelope_ibfk_1; +alter table dbmail_envelope drop foreign key dbmail_envelope_ibfk_2; +alter table dbmail_envelope add CONSTRAINT dbmail_envelope_ibfk_1 + FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + SET FOREIGN_KEY_CHECKS=1; _______________________________________________ DBmail mailing list DBmail [at] dbmail https://mailman.fastxs.nl/mailman/listinfo/dbmail
|