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

Laravel migrate postgres comment() don't work #18782

Closed
HaroldV opened this issue Apr 11, 2017 · 11 comments
Closed

Laravel migrate postgres comment() don't work #18782

HaroldV opened this issue Apr 11, 2017 · 11 comments

Comments

@HaroldV
Copy link

HaroldV commented Apr 11, 2017

  • Laravel Version: 5.4
  • PHP Version: 7.0
  • Database Driver & Version: Postgresql

Description:

Do not work function comment in the migration with postgresql

Steps To Reproduce:

this is in the migrate = $table->string('name',35)->nullable(false)->comment('Status Name');
I execute migrate and nothing

@Dylan-DPC-zz
Copy link

@HaroldV steps to reproduce?

@HaroldV
Copy link
Author

HaroldV commented Apr 19, 2017

this is in the migrate = $table->string('name',35)->nullable(false)->comment('Status Name');
I execute migrate and nothing

@andrey-helldar
Copy link
Contributor

Maybe, There is no COMMENT command in the SQL standard.
https://www.postgresql.org/docs/9.5/static/sql-comment.html

@garbinmarcelo
Copy link

Did you find any solution?

@HaroldV
Copy link
Author

HaroldV commented Apr 24, 2017

no marcelogarbin :(

@ghunti
Copy link
Contributor

ghunti commented May 21, 2017

I have the same issue.
For now I'm issuing a new command just for the comment: DB::select("COMMENT ON COLUMN table_name.column_name IS 'the comment'");

@diegorm221
Copy link

I made a project with the versions that you wrote, i think is a problem with your postgres version, test with 9.4 version or later.
I made in the migration:
public function up()
{
Schema::create('table_name', function (Blueprint $table) {
$table-> string('name', 35)->nullable(false)->comment('Status Name');
});
}

@ghunti
Copy link
Contributor

ghunti commented Jul 13, 2017

@Diego0037 The command you wrote creates the column but it doesn't create the comment. Did you check if you have the comment on that column with a postgresl client?? Looking at Laravel source code I don't think it supports comments for Postgresql but I might be wrong.
I'm using Postgres 9.6 and I had to do the manual comment with a DB::statement.

@vaughany
Copy link
Contributor

vaughany commented Aug 2, 2017

I can confirm that in Postgres 9.5.7, the following snippet creates a char column but without a comment:

$table->char('char')->default('some default')->comment('this is a comment');

\d+ test command in psql:

Column  |      Type      |                 Modifiers                 | Storage  | Stats target | Description 
--------+----------------+-------------------------------------------+----------+--------------+-------------
char    | character(255) | not null default 'some default'::bpchar   | extended |              | 

@bardrotzer
Copy link

bardrotzer commented Sep 11, 2017

I'm not sure how to implement this, but looking at the documentation for postgres it implements a different syntax for adding comments. As of today only MySql comments are supported for Laravel.

Something along this line would be needed to get comments working in PostgresGrammar.php

    protected function modifyComment(Blueprint $blueprint, Fluent $column)
    {
        if (! is_null($column->comment)) {
            return " COMMENT ON COLUMN ". getColumnNameMethod()." '".addslashes($column->comment)."';"
        }
    }

I have not tested this as I am quite new with laravel. Just to be clear, there is no getcolumnNameMethod just to highlight that we need some way of getting the "my_table.my_column" values

Any ideas if this may work?

andersondanilo added a commit to andersondanilo/framework that referenced this issue Oct 28, 2017
@mfn
Copy link
Contributor

mfn commented Dec 16, 2017

I believe this issue can be closed; the references PR implements this for postgres.

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

10 participants