Skip to content

Commit

Permalink
auto increment the ordering column
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Jul 13, 2023
1 parent a8fa1b2 commit 238ec17
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE `#__menu_types` ADD COLUMN `ordering` int NOT NULL DEFAULT 0 AFTER `client_id`;
ALTER TABLE `#__menu_types` ADD COLUMN `ordering` int NOT NULL AUTO_INCREMENT AFTER `client_id`;
UPDATE `#__menu_types` SET `ordering` = `id` WHERE `client_id` = 0;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE "#__menu_types" ADD COLUMN "ordering" int NOT NULL DEFAULT 0 AFTER "client_id";
ALTER TABLE "#__menu_types" ADD COLUMN "ordering" SERIAL NOT NULL AFTER "client_id";
UPDATE "#__menu_types" SET "ordering" = "id" WHERE "client_id" = 0;
2 changes: 1 addition & 1 deletion installation/sql/mysql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ CREATE TABLE IF NOT EXISTS `#__menu_types` (
`title` varchar(48) NOT NULL,
`description` varchar(255) NOT NULL DEFAULT '',
`client_id` int NOT NULL DEFAULT 0,
`ordering` int NOT NULL DEFAULT 0,
`ordering` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_menutype` (`menutype`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
Expand Down
2 changes: 1 addition & 1 deletion installation/sql/postgresql/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ CREATE TABLE IF NOT EXISTS "#__menu_types" (
"title" varchar(48) NOT NULL,
"description" varchar(255) DEFAULT '' NOT NULL,
"client_id" int DEFAULT 0 NOT NULL,
"ordering" int NOT NULL DEFAULT 0,
"ordering" serial NOT NULL,
PRIMARY KEY ("id"),
CONSTRAINT "#__menu_types_idx_menutype" UNIQUE ("menutype")
);
Expand Down

0 comments on commit 238ec17

Please sign in to comment.