Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

UNIQUE key on the sus_login_name column

Questions related to using nuBuilder Forte.
Post Reply
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

UNIQUE key on the sus_login_name column

Unread post by miasoft »

For the zzzzsys_user table, after each update, I add a UNIQUE key on the sus_login_name column. I don't understand why this key is not set by default?
Wbr, miasoft.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by kev1n »

Do you mean a unique constraint?
Why would you want to add it?

All changes to zzzz-tables are overwritten with an update.
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by miasoft »

kev1n wrote: Tue Jul 12, 2022 5:12 am Do you mean a unique constraint?
Why would you want to add it?
How is the uniqueness of sus_login_name checked? MySql rules or PHP-code? UNIQUE key needed for non-NUBuider programm (for me)
Wbr, miasoft.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by kev1n »

Uniqueness is ensured by code.
I might be able to provide some post-update functionality that allows you to run scripts after each update.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by kev1n »

Does that make sense?
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by miasoft »

kev1n wrote: Mon Jul 18, 2022 8:49 pm Does that make sense?
It doesn't bother me :)
Wbr, miasoft.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by kev1n »

There's now a possibility to run scripts after each update.

If the Procedure called nuAfterUpdate function exists, it will be run after an update.

Example:
nuAfterUpdate.png

Code: Select all

// Add a unique key to zzzzsys_user.sus_login_name
nuRunQuery(" ALTER TABLE `zzzzsys_user` ADD UNIQUE(`sus_login_name`) ";
You do not have the required permissions to view the files attached to this post.
miasoft
Posts: 156
Joined: Wed Dec 23, 2020 12:28 pm
Location: Russia, Volgograd
Has thanked: 32 times
Been thanked: 7 times
Contact:

Re: UNIQUE key on the sus_login_name column

Unread post by miasoft »

Thanks! I updated from Github. All work fine.
It's typo in script. Corrected:

Code: Select all

nuRunQuery(" ALTER TABLE `zzzzsys_user` ADD UNIQUE(`sus_login_name`) ");
Wbr, miasoft.
Post Reply