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

Update Option is not allowed and Docs suggestion #264

Open
Declan-Watts opened this issue Nov 5, 2021 · 3 comments
Open

Update Option is not allowed and Docs suggestion #264

Declan-Watts opened this issue Nov 5, 2021 · 3 comments
Milestone

Comments

@Declan-Watts
Copy link

Hi,
I am new to using Phoenix, and have implemented it for some of our systems. We have a field called "updated_at" with a default field of "CURRENT_TIMESTAMP" and an "ON UPDATE" of "CURRENT_TIMESTAMP" aswell. I am getting an error "Setting 'update' is not allowed.".

The code I used was this

$this->table("awards")
      ->addColumn('id', 'integer', ['autoincrement' => true])
      ->addColumn('name', 'longtext', ['null' => true])
      ->addColumn('shortName', 'string', ['null' => true, 'length' => 50])
      ->addColumn('typeExpiry', 'integer', ['default' => 0])
      ->addColumn('created_at', 'timestamp', ['default' => 'CURRENT_TIMESTAMP'])
      ->addColumn('updated_at', 'timestamp', ['default' => "CURRENT_TIMESTAMP", 'update' => "CURRENT_TIMESTAMP"])
      ->addColumn('hidden_at', 'timestamp', ['null' => true])
      ->create();

I also struggled to find out what the option for this even was. I could not find any documentation around the different options that are available for fields. I did however see that this was following Phinx quite closely and assumed that those docs might work. I think if this is supposed to replace phinx, it either should have the docs of what options are supported, or support all of phinx's options and just have a link to their documentation so people don't get lost/confused to what the syntax is etc.

Appreciate any help

@lulco
Copy link
Owner

lulco commented Nov 6, 2021

Hi, thank you for your report. In time when Phoenix was created, I wanted to support only features that are common for both mysql and psql. As I personally don't use ON UPDATE event and also it is not supported by psql, it is not implemented. For now, you can use only plain query. Or if you want, you can implement it.

You are also right about documentation of column settings. We need to add this part.

@Declan-Watts
Copy link
Author

Hi @lulco,

I am willing to implement this if you wish, I think it would be super handy. Also could give a hand on better documentation if you wish.

@lulco
Copy link
Owner

lulco commented Nov 6, 2021

I'd appreciate PRs for both. So go for it :)

@lulco lulco added this to the 2.1.0 milestone Dec 19, 2021
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

2 participants