Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
45b8cca9
Commit
45b8cca9
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
Fix the upgrade scripts
parent
f7384359
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/upgrader/streams/core/d51f303a-DYNAMICF.cleanup.sql
+66
-0
66 additions, 0 deletions
include/upgrader/streams/core/d51f303a-DYNAMICF.cleanup.sql
include/upgrader/streams/core/d51f303a-DYNAMICF.patch.sql
+6
-73
6 additions, 73 deletions
include/upgrader/streams/core/d51f303a-DYNAMICF.patch.sql
with
72 additions
and
73 deletions
include/upgrader/streams/core/d51f303a-DYNAMICF.cleanup.sql
0 → 100644
+
66
−
0
View file @
45b8cca9
-- Port data from the ticket table
-- 1. Create form entries for each ticket
INSERT
INTO
`%TABLE_PREFIX%form_entry`
(
`section_id`
,
`ticket_id`
,
`sort`
,
`created`
,
`updated`
)
SELECT
1
,
`ticket_id`
,
10
,
`created`
,
`updated`
FROM
`%TABLE_PREFIX%ticket`
;
-- 2. Copy subject lines from the ticket table into section #2
INSERT
INTO
`%TABLE_PREFIX%form_entry_values`
(
`field_id`
,
`entry_id`
,
`value`
)
SELECT
A3
.
`field_id`
,
A2
.
`id`
,
A1
.
`subject`
FROM
`%TABLE_PREFIX%ticket`
A1
INNER
JOIN
`%TABLE_PREFIX%form_entry`
A2
ON
(
A1
.
`ticket_id`
=
A2
.
`ticket_id`
AND
A2
.
`section_id`
=
2
),
INNER
JOIN
`%TABLE_PREFIX%form_field`
A3
ON
(
A2
.
`section_id`
=
A3
.
`section_id`
)
WHERE
A3
.
`name`
=
'subject'
;
-- TODO: Move this to a client info dynamic entry
-- 3. Copy Phone from the ticket table to section #1
INSERT
INTO
`%TABLE_PREFIX%form_entry_values`
(
`field_id`
,
`entry_id`
,
`value`
)
SELECT
A3
.
`field_id`
,
A2
.
`id`
,
CONCAT
(
A1
.
`phone`
,
'X'
,
A1
.
`phone_ext`
)
FROM
`%TABLE_PREFIX%ticket`
A1
INNER
JOIN
`%TABLE_PREFIX%form_entry`
A2
ON
(
A1
.
`ticket_id`
=
A2
.
`ticket_id`
AND
A2
.
`section_id`
=
1
),
INNER
JOIN
`%TABLE_PREFIX%form_field`
A3
ON
(
A2
.
`section_id`
=
A3
.
`section_id`
)
WHERE
A3
.
`name`
=
'phone'
AND
LENGTH
(
A1
.
`phone`
);
-- 4. Create <user> accounts for everybody
-- - Start with creating email addresses for the accounts
INSERT
INTO
`%TABLE_PREFIX%user_email`
(
`address`
)
SELECT
DISTINCT
`email`
FROM
`%TABLE_PREFIX%ticket`
;
-- - Then create the accounts and link the `default_email`s
INSERT
INTO
`%TABLE_PREFIX%user`
(
`first`
,
`default_email_id`
)
SELECT
MAX
(
`name`
),
A2
.
`id`
FROM
`%TABLE_PREFIX%ticket`
A1
INNER
JOIN
`%TABLE_PREFIX%user_email`
A2
ON
(
A1
.
`email`
=
A2
.
`address`
);
GROUP
BY
A2
.
`id`
-- - Now link the user and user_email tables
ALTER
TABLE
`%TABLE_PREFIX%user`
ADD
KEY
`def_eml_id`
(
`default_email_id`
,
`id`
);
UPDATE
`%TABLE_PREFIX%user_email`
A1
SET
user_id
=
(
SELECT
A2
.
`id`
FROM
`%TABLE_PREFIX%user`
A2
WHERE
`default_email_id`
=
A1
.
`id`
);
ALTER
TABLE
`%TABLE_PREFIX%user`
DROP
INDEX
`def_eml_id`
;
-- - Update the ticket table
UPDATE
`%TABLE_PREFIX%ticket`
A1
JOIN
`%TABLE_PREFIX%user_email`
A2
ON
A2
.
`address`
=
A1
.
`email`
SET
`user_id`
=
A2
.
`user_id`
,
`user_email_id`
=
A2
.
`id`
;
-- 4. Remove columns from ticket table
ALTER
TABLE
`%TABLE_PREFIX%ticket`
DROP
COLUMN
`name`
,
DROP
COLUMN
`email`
,
DROP
COLUMN
`phone`
,
DROP
COLUMN
`phone_ext`
,
DROP
COLUMN
`subject`
;
-- 5. Cleanup ticket table with dropped varchar columns
OPTIMIZE
TABLE
`%TABLE_PREFIX%ticket`
;
This diff is collapsed.
Click to expand it.
include/upgrader/streams/core/d51f303a-DYNAMICF.patch.sql
+
6
−
73
View file @
45b8cca9
/**
* @version v1.
7.1
* @version v1.
8.0-dpr1 Dynamic Forms
* @signature 0000000000000000000000000000000
*
* Adds the database structure for the dynamic forms feature and migrates
...
...
@@ -31,7 +31,7 @@ CREATE TABLE `%TABLE_PREFIX%form_field` (
`label`
varchar
(
255
)
NOT
NULL
,
`required`
tinyint
(
1
)
NOT
NULL
DEFAULT
0
,
`private`
tinyint
(
1
)
NOT
NULL
DEFAULT
0
,
`edit_mask`
tinyint
(
1
)
NOT
NULL
DEFAULT
1
,
`edit_mask`
tinyint
(
1
)
NOT
NULL
DEFAULT
0
,
`name`
varchar
(
64
)
NOT
NULL
,
`configuration`
text
,
`sort`
int
(
11
)
unsigned
NOT
NULL
,
...
...
@@ -111,80 +111,13 @@ ALTER TABLE `%TABLE_PREFIX%filter_rule`
CHANGE
`what`
`what`
varchar
(
32
)
NOT
NULL
;
ALTER
TABLE
`%TABLE_PREFIX%help_topic`
ADD
`formset_id`
int
(
11
)
unsigned
NOT
NULL
default
'0'
AFTER
`sla_id`
;
ADD
`formset_id`
int
(
11
)
unsigned
NOT
NULL
default
'0'
AFTER
`sla_id`
;
-- Port data from the ticket table
-- 1. Create form entries for each ticket
INSERT
INTO
`%TABLE_PREFIX%form_entry`
(
`section_id`
,
`ticket_id`
,
`sort`
,
`created`
,
`updated`
)
SELECT
1
,
`ticket_id`
,
10
,
`created`
,
`updated`
FROM
`%TABLE_PREFIX%ticket`
;
-- 2. Copy subject lines from the ticket table into section #2
INSERT
INTO
`%TABLE_PREFIX%form_entry_values`
(
`field_id`
,
`entry_id`
,
`value`
)
SELECT
A3
.
`field_id`
,
A2
.
`id`
,
A1
.
`subject`
FROM
`%TABLE_PREFIX%ticket`
A1
INNER
JOIN
`%TABLE_PREFIX%form_entry`
A2
ON
(
A1
.
`ticket_id`
=
A2
.
`ticket_id`
AND
A2
.
`section_id`
=
2
),
INNER
JOIN
`%TABLE_PREFIX%form_field`
A3
ON
(
A2
.
`section_id`
=
A3
.
`section_id`
)
WHERE
A3
.
`name`
=
'subject'
;
-- TODO: Move this to a client info dynamic entry
-- 3. Copy Phone from the ticket table to section #1
INSERT
INTO
`%TABLE_PREFIX%form_entry_values`
(
`field_id`
,
`entry_id`
,
`value`
)
SELECT
A3
.
`field_id`
,
A2
.
`id`
,
CONCAT
(
A1
.
`phone`
,
'X'
,
A1
.
`phone_ext`
)
FROM
`%TABLE_PREFIX%ticket`
A1
INNER
JOIN
`%TABLE_PREFIX%form_entry`
A2
ON
(
A1
.
`ticket_id`
=
A2
.
`ticket_id`
AND
A2
.
`section_id`
=
1
),
INNER
JOIN
`%TABLE_PREFIX%form_field`
A3
ON
(
A2
.
`section_id`
=
A3
.
`section_id`
)
WHERE
A3
.
`name`
=
'phone'
AND
LENGTH
(
A1
.
`phone`
);
-- 4. Create <user> accounts for everybody
-- - Start with creating email addresses for the accounts
INSERT
INTO
`%TABLE_PREFIX%user_email`
(
`address`
)
SELECT
DISTINCT
`email`
FROM
`%TABLE_PREFIX%ticket`
;
-- - Then create the accounts and link the `default_email`s
INSERT
INTO
`%TABLE_PREFIX%user`
(
`first`
,
`default_email_id`
)
SELECT
MAX
(
`name`
),
A2
.
`id`
FROM
`%TABLE_PREFIX%ticket`
A1
INNER
JOIN
`%TABLE_PREFIX%user_email`
A2
ON
(
A1
.
`email`
=
A2
.
`address`
);
GROUP
BY
A2
.
`id`
-- - Now link the user and user_email tables
ALTER
TABLE
`%TABLE_PREFIX%user`
ADD
KEY
`def_eml_id`
(
`default_email_id`
,
`id`
);
UPDATE
`%TABLE_PREFIX%user_email`
A1
SET
user_id
=
(
SELECT
A2
.
`id`
FROM
`%TABLE_PREFIX%user`
A2
WHERE
`default_email_id`
=
A1
.
`id`
);
ALTER
TABLE
`%TABLE_PREFIX%user`
DROP
INDEX
`def_eml_id`
;
-- - Update the ticket table
ALTER
TABLE
`%TABLE_PREFIX%ticket`
ADD
`user_id`
int
(
11
)
UNSIGNED
NOT
NULL
DEFAULT
0
AFTER
`ticket_id`
,
ADD
`user_email_id`
int
(
11
)
UNSIGNED
NOT
NULL
DEFAULT
0
AFTER
`user_id`
;
UPDATE
`%TABLE_PREFIX%ticket`
A1
JOIN
`%TABLE_PREFIX%user_email`
A2
ON
A2
.
`address`
=
A1
.
`email`
SET
`user_id`
=
A2
.
`user_id`
,
`user_email_id`
=
A2
.
`id`
;
-- 4. Remove columns from ticket table
ALTER
TABLE
`%TABLE_PREFIX%ticket`
DROP
COLUMN
`name`
,
DROP
COLUMN
`email`
,
DROP
COLUMN
`phone`
,
DROP
COLUMN
`phone_ext`
,
DROP
COLUMN
`subject`
;
-- 5. Cleanup ticket table with dropped varchar columns
OPTIMIZE
TABLE
`%TABLE_PREFIX%ticket`
;
-- update schema signature.
-- Finished with patch
UPDATE
`%TABLE_PREFIX%config`
SET
`schema_signature`
=
'0000000000000000000000000000000'
;
SET
`value`
=
'00000000000000000000000000000000'
WHERE
`key`
=
'schema_signature'
AND
`namespace`
=
'core'
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment