Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stripe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
Stripe
Commits
5512c2dd
Commit
5512c2dd
authored
8 years ago
by
Peter Hartmann
Browse files
Options
Downloads
Patches
Plain Diff
issue #191
parent
5c243da3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Stripe/Upgrader.php
+28
-13
28 additions, 13 deletions
CRM/Stripe/Upgrader.php
with
28 additions
and
13 deletions
CRM/Stripe/Upgrader.php
+
28
−
13
View file @
5512c2dd
...
...
@@ -45,18 +45,6 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
else
{
$this
->
ctx
->
log
->
info
(
'Skipped civicrm_stripe update 1903. Column is_live already present on civicrm_stripe_plans table.'
);
}
$sql
=
"SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = %1 AND TABLE_NAME = 'civicrm_stripe_customers' AND COLUMN_KEY = 'MUL'"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
,
array
(
1
=>
array
(
$dbName
,
'String'
)));
$key_column_exists
=
$dao
->
N
==
0
?
FALSE
:
TRUE
;
if
(
$key_column_exists
)
{
$this
->
ctx
->
log
->
info
(
'Applying civicrm_stripe update 1903. Setting unique key from email to id on civicrm_stripe_plans table.'
);
CRM_Core_DAO
::
executeQuery
(
'ALTER TABLE `civicrm_stripe_customers` DROP INDEX email'
);
CRM_Core_DAO
::
executeQuery
(
'ALTER TABLE `civicrm_stripe_customers` ADD UNIQUE (id)'
);
}
else
{
$this
->
ctx
->
log
->
info
(
'Skipped civicrm_stripe update 1903. Unique key already changed from email to id on civicrm_stripe_plans table.'
);
}
return
TRUE
;
}
...
...
@@ -344,7 +332,7 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
*/
/**
* Add change default NOT NULL to NULL in vestigial invoice_id column in civicrm_stripe_subscriptions table if needed. (issue #19
1
)
* Add change default NOT NULL to NULL in vestigial invoice_id column in civicrm_stripe_subscriptions table if needed. (issue #19
2
)
*
* @return TRUE on success
* @throws Exception
...
...
@@ -367,4 +355,31 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
}
return
TRUE
;
}
/**
* Add remove unique from email and add to customer in civicrm_stripe_customers tables. (issue #191)
*
* @return TRUE on success
* @throws Exception
*/
public
function
upgrade_5009
()
{
$config
=
CRM_Core_Config
::
singleton
();
$dbName
=
DB
::
connect
(
$config
->
dsn
)
->
_db
;
$sql
=
"SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = %1
AND TABLE_NAME = 'civicrm_stripe_customers'
AND COLUMN_NAME = 'id'
AND COLUMN_KEY = 'UNI'"
;
$dao
=
CRM_Core_DAO
::
executeQuery
(
$sql
,
array
(
1
=>
array
(
$dbName
,
'String'
)));
if
(
$dao
->
N
)
{
$this
->
ctx
->
log
->
info
(
'id is already unique in civicrm_stripe_customers table, no need for civicrm_stripe update 5009.'
);
}
else
{
$this
->
ctx
->
log
->
info
(
'Applying civicrm_stripe update 5009. Setting unique key from email to id on civicrm_stripe_plans table.'
);
CRM_Core_DAO
::
executeQuery
(
'ALTER TABLE `civicrm_stripe_customers` DROP INDEX email'
);
CRM_Core_DAO
::
executeQuery
(
'ALTER TABLE `civicrm_stripe_customers` ADD UNIQUE (id)'
);
}
return
TRUE
;
}
}
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