Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nextcloud-forms
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Milan Jaros
nextcloud-forms
Commits
d2effbdb
Unverified
Commit
d2effbdb
authored
3 years ago
by
Jonas Rittershofer
Browse files
Options
Downloads
Patches
Plain Diff
Fix boolean columns nullable
Signed-off-by:
Jonas Rittershofer
<
jotoeri@users.noreply.github.com
>
parent
f5b2bcaf
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
lib/Migration/Version010200Date20200323141300.php
+3
-3
3 additions, 3 deletions
lib/Migration/Version010200Date20200323141300.php
lib/Migration/Version020300Date20210403214012.php
+64
-0
64 additions, 0 deletions
lib/Migration/Version020300Date20210403214012.php
with
67 additions
and
3 deletions
lib/Migration/Version010200Date20200323141300.php
+
3
−
3
View file @
d2effbdb
...
...
@@ -114,11 +114,11 @@ class Version010200Date20200323141300 extends SimpleMigrationStep {
'comment'
=>
'unix-timestamp'
,
]);
$table
->
addColumn
(
'is_anonymous'
,
self
::
TYPE_BOOLEAN
,
[
'notnull'
=>
tru
e
,
'notnull'
=>
fals
e
,
'default'
=>
0
,
]);
$table
->
addColumn
(
'submit_once'
,
self
::
TYPE_BOOLEAN
,
[
'notnull'
=>
tru
e
,
'notnull'
=>
fals
e
,
'default'
=>
0
,
]);
$table
->
setPrimaryKey
([
'id'
]);
...
...
@@ -143,7 +143,7 @@ class Version010200Date20200323141300 extends SimpleMigrationStep {
'length'
=>
256
,
]);
$table
->
addColumn
(
'mandatory'
,
self
::
TYPE_BOOLEAN
,
[
'notnull'
=>
tru
e
,
'notnull'
=>
fals
e
,
'default'
=>
0
,
]);
$table
->
addColumn
(
'text'
,
self
::
TYPE_STRING
,
[
...
...
This diff is collapsed.
Click to expand it.
lib/Migration/Version020300Date20210403214012.php
0 → 100644
+
64
−
0
View file @
d2effbdb
<?php
declare
(
strict_types
=
1
);
/**
* @copyright Copyright (c) 2021 Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @author Joas Schilling <coding@schilljs.com>
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace
OCA\Forms\Migration
;
use
Closure
;
use
OCP\DB\ISchemaWrapper
;
use
OCP\Migration\IOutput
;
use
OCP\Migration\SimpleMigrationStep
;
class
Version020300Date20210403214012
extends
SimpleMigrationStep
{
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public
function
changeSchema
(
IOutput
$output
,
Closure
$schemaClosure
,
array
$options
):
?ISchemaWrapper
{
/** @var ISchemaWrapper $schema */
$schema
=
$schemaClosure
();
$result
=
$this
->
ensureColumnIsNullable
(
$schema
,
'forms_v2_forms'
,
'is_anonymous'
);
$result
|=
$this
->
ensureColumnIsNullable
(
$schema
,
'forms_v2_forms'
,
'submit_once'
);
$result
|=
$this
->
ensureColumnIsNullable
(
$schema
,
'forms_v2_questions'
,
'mandatory'
);
return
$result
?
$schema
:
null
;
}
protected
function
ensureColumnIsNullable
(
ISchemaWrapper
$schema
,
string
$tableName
,
string
$columnName
):
bool
{
$table
=
$schema
->
getTable
(
$tableName
);
$column
=
$table
->
getColumn
(
$columnName
);
if
(
$column
->
getNotnull
())
{
$column
->
setNotnull
(
false
);
return
true
;
}
return
false
;
}
}
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