Skip to content
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

Wrong column size for numeric columns in MySQL #139

Open
wurst-hans opened this issue Feb 15, 2023 · 0 comments
Open

Wrong column size for numeric columns in MySQL #139

wurst-hans opened this issue Feb 15, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@wurst-hans
Copy link

Using Phalcon Migrations 2.2.4 with MySQL and MariaDB (current v8 releases).

When creating a dump, the migration files for tables using numeric columns (i.e. TYPE_TINYINT, TYPE_INT, TYPE_BIGINT) are created using size=1. Ex.:

new Column(
    'id',
    [
        'type' => Column::TYPE_BIGINTEGER,
        'notNull' => true,
        'autoIncrement' => true,
        'size' => 1,
        'first' => true
    ]
),

Which results in creating the tables like

CREATE TABLE `sessions` (
  `id` bigint(1) NOT NULL,
  `session_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  `user_id` int(1) DEFAULT NULL,
  `data` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci,
  `timeout` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

But default "column size" in MySQL is 4 for TINYINT, 11 for INT and 20 for BIGINT. I know, that this is not the real internal column definition but the display representation only. But this confuses me a lot, when opening database using PhpMyAdmin and I see tons of columns having definition INT(1).

@Jeckerson Jeckerson self-assigned this May 29, 2023
@Jeckerson Jeckerson added the bug Something isn't working label May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants