-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add BigInt column type support and update related classes #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ArnabChatterjee20k
wants to merge
3
commits into
main
Choose a base branch
from
big-int
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+169
−81
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <?php | ||
|
|
||
| namespace Utopia\Migration\Resources\Database\Columns; | ||
|
|
||
| use Utopia\Migration\Resources\Database\Column; | ||
| use Utopia\Migration\Resources\Database\Table; | ||
|
|
||
| class BigInt extends Column | ||
| { | ||
| public function __construct( | ||
| string $key, | ||
| Table $table, | ||
| bool $required = false, | ||
| ?int $default = null, | ||
| bool $array = false, | ||
| ?int $min = null, | ||
| ?int $max = null, | ||
| bool $signed = true, | ||
| string $createdAt = '', | ||
| string $updatedAt = '' | ||
| ) { | ||
| $min ??= PHP_INT_MIN; | ||
| $max ??= PHP_INT_MAX; | ||
| $size = 8; | ||
|
|
||
| parent::__construct( | ||
| $key, | ||
| $table, | ||
| size: $size, | ||
| required: $required, | ||
| default: $default, | ||
| array: $array, | ||
| signed: $signed, | ||
| formatOptions: [ | ||
| 'min' => $min, | ||
| 'max' => $max, | ||
| ], | ||
| createdAt: $createdAt, | ||
| updatedAt: $updatedAt | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @param array{ | ||
| * key: string, | ||
| * collection?: array{ | ||
| * database: array{ | ||
| * id: string, | ||
| * name: string, | ||
| * }, | ||
| * name: string, | ||
| * id: string, | ||
| * documentSecurity: bool, | ||
| * permissions: ?array<string> | ||
| * }, | ||
| * table?: array{ | ||
| * database: array{ | ||
| * id: string, | ||
| * name: string, | ||
| * }, | ||
| * name: string, | ||
| * id: string, | ||
| * rowSecurity: bool, | ||
| * permissions: ?array<string> | ||
| * }, | ||
| * required: bool, | ||
| * array: bool, | ||
| * default: ?int, | ||
| * formatOptions: array{ | ||
| * min: ?int, | ||
| * max: ?int | ||
| * }, | ||
| * createdAt: string, | ||
| * updatedAt: string, | ||
| * } $array | ||
| * @return self | ||
| */ | ||
| public static function fromArray(array $array): self | ||
| { | ||
| return new self( | ||
| $array['key'], | ||
| Table::fromArray($array['table'] ?? $array['collection']), | ||
| required: $array['required'], | ||
| default: $array['default'], | ||
| array: $array['array'], | ||
| min: $array['formatOptions']['min'] ?? null, | ||
| max: $array['formatOptions']['max'] ?? null, | ||
| signed: $array['signed'] ?? true, | ||
| createdAt: $array['createdAt'] ?? '', | ||
| updatedAt: $array['updatedAt'] ?? '', | ||
| ); | ||
ArnabChatterjee20k marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public function getType(): string | ||
| { | ||
| return Column::TYPE_BIG_INT; | ||
| } | ||
|
|
||
| public function getMin(): ?int | ||
| { | ||
| return (int)$this->formatOptions['min']; | ||
| } | ||
|
|
||
| public function getMax(): ?int | ||
| { | ||
| return (int)$this->formatOptions['max']; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency is pinned to
dev-big-init as 5.4, a development branch ofutopia-php/databasethat has not been released as a stable version. This creates several production risks:big-initbranch can be force-pushed, rebased, or deleted at any time, breakingcomposer installfor anyone pulling this library."minimum-stability": "stable"declared incomposer.jsonis effectively bypassed via thestability-flagsoverride incomposer.lock(flag value20= dev-level stability).This PR should be blocked until
utopia-php/databasehas an official tagged release (e.g.5.4.0) that includes BigInt support, at which point the constraint should be updated to"utopia-php/database": "5.4.*"or"5.*".