Skip to content

Remove valias primary key#14

Open
semhoun wants to merge 2 commits intobrunonymous:mainfrom
semhoun:fix/valias_mysql
Open

Remove valias primary key#14
semhoun wants to merge 2 commits intobrunonymous:mainfrom
semhoun:fix/valias_mysql

Conversation

@semhoun
Copy link
Copy Markdown
Contributor

@semhoun semhoun commented Sep 6, 2024

The primary key block the insertion of a second valias row with the same alias/domain.

The primary key block the insertion of  a second valias row with the same alias/domain.
@sagredo-dev
Copy link
Copy Markdown
Contributor

sagredo-dev commented Sep 8, 2024

Nathanaël is right. I propose to turn it into a simple INDEX. Also I'm creating an alternative primary, as it seems to me that phpmyadmin doesn't show the modify button otherwise.

diff --git a/ChangeLog b/ChangeLog
index cd55b43..0380f0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@ or info related to the entry. http://sourceforge.net/projects/vpopmail/
unreleased
- fixed a configure break where a trivial C test program exits on error with gcc-14.1 due to missing headers
- vusaged/domain.c: fixed -Wimplicit-function-declaration compilation warning
+ - vmysql.h: dropped the multicolumn PRIMARY KEY in valias table to allow multiple forwards for a given alias.
+ In case one already has the valias table defined, this is the sql query for the upgrade:
+ ALTER TABLE vpopmail.valias DROP PRIMARY KEY, ADD INDEX (alias, domain, valias_type) USING BTREE;
+ ALTER TABLE vpopmail.valias ADD id INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (id);

5.6.1
- vmysql.c: allow the insertion of a second valias row with the same alias/domain
diff --git a/vmysql.h b/vmysql.h
index 0597ad3..0d4af18 100644
--- a/vmysql.h
+++ b/vmysql.h
@@ -245,12 +245,13 @@ level_index0, level_index1, level_index2, the_dir"

#ifdef DEFAULT_DELIVERY
#define VALIAS_TABLE_LAYOUT
-"valias_type tinyint(1) NOT NULL DEFAULT 1 COMMENT '1=forwarder 0=lda',
+"id int(11) PRIMARY KEY AUTO_INCREMENT,
+valias_type tinyint(1) NOT NULL DEFAULT 1 COMMENT '1=forwarder 0=lda',
alias char(32) NOT NULL,
domain char(96) NOT NULL,
valias_line text NOT NULL,
copy tinyint(1) NOT NULL DEFAULT 0 COMMENT '0=redirect 1=copy&redirect',
-PRIMARY KEY (alias,domain,valias_type),
+INDEX (alias,domain,valias_type),
INDEX (alias, domain)"
#else
#define VALIAS_TABLE_LAYOUT "id int(11) PRIMARY KEY AUTO_INCREMENT, \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants