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

comment() does not work in migrations #2404

Open
sawa-ko opened this issue Oct 28, 2024 · 0 comments
Open

comment() does not work in migrations #2404

sawa-ko opened this issue Oct 28, 2024 · 0 comments

Comments

@sawa-ko
Copy link

sawa-ko commented Oct 28, 2024

Description

I am using the “comment()” option in the migrations but when I run it, it does nothing, it does not add the comments.

        manager
            .create_table(
                Table::create()
                    .table(AnimeFavorites::Table)
                    .if_not_exists()
                    .col(pk_uuid(AnimeFavorites::Id))
                    .col(
                        integer(AnimeFavorites::AnimeId)
                            .not_null()
                            .comment("ID of the anime within the platform from which your data was obtained."),
                    )
                    .col(
                        integer(AnimeFavorites::UserId)
                            .not_null()
                            .comment("ID of the user who marked it as a favorite. This is a many to one relationship."),
                    )
                    .col(
                        string(AnimeFavorites::Platform)
                            .custom(AnimePlatforms::Enum)
                            .comment("Name of the platform from which the information about the anime was obtained."),
                    )
                    .to_owned(),
            )
            .await?;

Steps to Reproduce

  1. Create a migration
  2. Use the comment() function when create a table column
  3. View the migration execution logs and see that the comments are missing.

Expected Behavior

Besides creating the columns, tables, etc., the assigned comments are also added.

Actual Behavior

Comments are not assigned to columns.

Reproduces How Often

Yes. Create a migration.

Workarounds

Reproducible Example

        manager
            .create_table(
                Table::create()
                    .table(AnimeFavorites::Table)
                    .if_not_exists()
                    .col(pk_uuid(AnimeFavorites::Id))
                    .col(
                        integer(AnimeFavorites::AnimeId)
                            .not_null()
                            .comment("ID of the anime within the platform from which your data was obtained."),
                    )
                    .col(
                        integer(AnimeFavorites::UserId)
                            .not_null()
                            .comment("ID of the user who marked it as a favorite. This is a many to one relationship."),
                    )
                    .col(
                        string(AnimeFavorites::Platform)
                            .custom(AnimePlatforms::Enum)
                            .comment("Name of the platform from which the information about the anime was obtained."),
                    )
                    .to_owned(),
            )
            .await?;
2024-10-28T15:51:02.341923Z  INFO Database startup: database: Running migrations...
2024-10-28T15:51:02.346621Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"seaql_migrations\" (\n  \"version\" varchar NOT NULL PRIMARY KEY,\n  \"applied_at\" bigint NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=3.216901ms elapsed_secs=0.003216901
2024-10-28T15:51:02.346694Z  INFO Database startup: sea_orm_migration::migrator: Applying all pending migrations
2024-10-28T15:51:02.347015Z  INFO Database startup: sqlx::postgres::notice: relation "seaql_migrations" already exists, skipping
2024-10-28T15:51:02.347939Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"seaql_migrations\" (\n  \"version\" varchar NOT NULL PRIMARY KEY,\n  \"applied_at\" bigint NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=300.909µs elapsed_secs=0.000300909
2024-10-28T15:51:02.348231Z  INFO Database startup: sqlx::postgres::notice: relation "seaql_migrations" already exists, skipping
2024-10-28T15:51:02.349154Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"seaql_migrations\" (\n  \"version\" varchar NOT NULL PRIMARY KEY,\n  \"applied_at\" bigint NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=242.94µs elapsed_secs=0.00024294
2024-10-28T15:51:02.349450Z  INFO Database startup: sqlx::postgres::notice: relation "seaql_migrations" already exists, skipping
2024-10-28T15:51:02.350304Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"seaql_migrations\" (\n  \"version\" varchar NOT NULL PRIMARY KEY,\n  \"applied_at\" bigint NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=249.743µs elapsed_secs=0.000249743
2024-10-28T15:51:02.351720Z  INFO Database startup: sqlx::query: summary="SELECT \"version\", \"applied_at\" FROM …" db.statement="\n\nSELECT\n  \"version\",\n  \"applied_at\"\nFROM\n  \"seaql_migrations\"\nORDER BY\n  \"version\" ASC\n" rows_affected=0 rows_returned=0 elapsed=788.613µs elapsed_secs=0.000788613
2024-10-28T15:51:02.351975Z  INFO Database startup: sea_orm_migration::migrator: Applying migration 'm20240827_154646_settings_user'
2024-10-28T15:51:02.353100Z  INFO Database startup: sqlx::query: summary="CREATE TYPE \"user_status\" AS …" db.statement="\n\nCREATE TYPE \"user_status\" AS ENUM ('disabled', 'active')\n" rows_affected=0 rows_returned=0 elapsed=652.886µs elapsed_secs=0.000652886
2024-10-28T15:51:02.357424Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"user_settings\" (\n  \"id\" bigserial NOT NULL PRIMARY KEY,\n  \"created_at\" timestamp with time zone NOT NULL NOT NULL DEFAULT 'NOW()',\n  \"updated_at\" timestamp with time zone NOT NULL NOT NULL DEFAULT 'NOW()',\n  \"status\" user_status NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=2.196739ms elapsed_secs=0.002196739
2024-10-28T15:51:02.357499Z  INFO Database startup: sea_orm_migration::migrator: Migration 'm20240827_154646_settings_user' has been applied
2024-10-28T15:51:02.358735Z  INFO Database startup: sqlx::query: summary="INSERT INTO \"seaql_migrations\" (\"version\", …" db.statement="\n\nINSERT INTO\n  \"seaql_migrations\" (\"version\", \"applied_at\")\nVALUES\n  ($1, $2)\nRETURNING\n  \"version\"\n" rows_affected=1 rows_returned=1 elapsed=608.241µs elapsed_secs=0.000608241
2024-10-28T15:51:02.358787Z  INFO Database startup: sea_orm_migration::migrator: Applying migration 'm20240829_223902_settings_anime_entity_and_relations'
2024-10-28T15:51:02.359611Z  INFO Database startup: sqlx::query: summary="CREATE TYPE \"anime_platforms\" AS …" db.statement="\n\nCREATE TYPE \"anime_platforms\" AS ENUM ('MAL')\n" rows_affected=0 rows_returned=0 elapsed=443.489µs elapsed_secs=0.000443489
2024-10-28T15:51:02.362624Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"anime_favorites\" (\n  \"id\" uuid NOT NULL PRIMARY KEY,\n  \"anime_id\" integer NOT NULL NOT NULL,\n  \"user_id\" integer NOT NULL NOT NULL,\n  \"platform\" anime_platforms NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=1.254005ms elapsed_secs=0.001254005
2024-10-28T15:51:02.365496Z  INFO Database startup: sqlx::query: summary="ALTER TABLE \"anime_favorites\" ADD …" db.statement="\n\nALTER TABLE\n  \"anime_favorites\"\nADD\n  CONSTRAINT \"fk_user\" FOREIGN KEY (\"user_id\") REFERENCES \"user_settings\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE\n" rows_affected=0 rows_returned=0 elapsed=2.315625ms elapsed_secs=0.002315625
2024-10-28T15:51:02.365556Z  INFO Database startup: sea_orm_migration::migrator: Migration 'm20240829_223902_settings_anime_entity_and_relations' has been applied
2024-10-28T15:51:02.366374Z  INFO Database startup: sqlx::query: summary="INSERT INTO \"seaql_migrations\" (\"version\", …" db.statement="\n\nINSERT INTO\n  \"seaql_migrations\" (\"version\", \"applied_at\")\nVALUES\n  ($1, $2)\nRETURNING\n  \"version\"\n" rows_affected=1 rows_returned=1 elapsed=272.857µs elapsed_secs=0.000272857
2024-10-28T15:51:02.366418Z  INFO Database startup: sea_orm_migration::migrator: Applying migration 'm20241028_145603_player_queue'
2024-10-28T15:51:02.373262Z  INFO Database startup: sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS \"player_queue\" (\n  \"id\" uuid NOT NULL PRIMARY KEY,\n  \"created_at\" timestamp with time zone NOT NULL NOT NULL DEFAULT 'NOW()',\n  \"updated_at\" timestamp with time zone NOT NULL NOT NULL DEFAULT 'NOW()',\n  \"guild_id\" bigint NOT NULL,\n  \"encoded\" varchar NOT NULL,\n  \"is_seekable\" bool NOT NULL,\n  \"author\" varchar NOT NULL,\n  \"length\" integer NOT NULL,\n  \"is_stream\" bool NOT NULL,\n  \"title\" varchar NOT NULL,\n  \"uri\" varchar NOT NULL,\n  \"artwork_url\" varchar NOT NULL,\n  \"isrc\" varchar NOT NULL,\n  \"source_name\" varchar NOT NULL\n)\n" rows_affected=0 rows_returned=0 elapsed=1.969088ms elapsed_secs=0.001969088
2024-10-28T15:51:02.374301Z  INFO Database startup: sqlx::query: summary="CREATE INDEX ON \"player_queue\" …" db.statement="\n\nCREATE INDEX ON \"player_queue\" (\"guild_id\")\n" rows_affected=0 rows_returned=0 elapsed=608.372µs elapsed_secs=0.000608372
2024-10-28T15:51:02.375057Z  INFO Database startup: sqlx::query: summary="CREATE INDEX ON \"player_queue\" …" db.statement="\n\nCREATE INDEX ON \"player_queue\" (\"uri\")\n" rows_affected=0 rows_returned=0 elapsed=455.412µs elapsed_secs=0.000455412
2024-10-28T15:51:02.375099Z  INFO Database startup: sea_orm_migration::migrator: Migration 'm20241028_145603_player_queue' has been applied
2024-10-28T15:51:02.375805Z  INFO Database startup: sqlx::query: summary="INSERT INTO \"seaql_migrations\" (\"version\", …" db.statement="\n\nINSERT INTO\n  \"seaql_migrations\" (\"version\", \"applied_at\")\nVALUES\n  ($1, $2)\nRETURNING\n  \"version\"\n" rows_affected=1 rows_returned=1 elapsed=172.316µs elapsed_secs=0.000172316
2024-10-28T15:51:02.376486Z  INFO Database startup: sqlx::query: summary="COMMIT" db.statement="" rows_affected=0 rows_returned=0 elapsed=621.357µs elapsed_secs=0.000621357
2024-10-28T15:51:02.376544Z  INFO Database startup: database: Migrations completed

Versions

cargo tree | grep sea-
│   │   ├── sea-orm v1.1.0
│   │   │   ├── sea-orm-macros v1.1.0 (proc-macro)
│   │   │   │   ├── sea-bae v0.2.1 (proc-macro)
│   │   │   ├── sea-query v0.32.0
│   │   │   │   ├── sea-query-derive v0.4.2 (proc-macro)
│   │   │   ├── sea-query-binder v0.7.0
│   │   │   │   ├── sea-query v0.32.0 (*)
│   │   └── sea-orm-migration v1.1.0
│   │       ├── sea-orm v1.1.0 (*)
│   │       ├── sea-orm-cli v1.1.0
│   │       │   ├── sea-schema v0.16.0
│   │       │   │   ├── sea-query v0.32.0 (*)
│   │       │   │   └── sea-schema-derive v0.3.0 (proc-macro)
│   │       ├── sea-schema v0.16.0 (*)
│   ├── sea-orm v1.1.0 (*)
├── sea-orm v1.1.0 (*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant