Comments (2)
Hello @kitloong
I fixed generated migration this way:
Schema::create('tabkeName', function (Blueprint $table) {
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
This result I got:
Column | Type | Collation | Nullable | Default |
---|---|---|---|---|
created_at | timestamp(0) without time zone | not null | CURRENT_TIMESTAMP | |
updated_at | timestamp(0) without time zone | not null | CURRENT_TIMESTAMP |
Laravel also provide $table->timestamp('updated_at')->useCurrentOnUpdate()
but, as I understood, it doesn't support Postgres, only MySQL:
namespace Illuminate\Database\Schema;
use Illuminate\Support\Fluent;
/**
* @method $this after(string $column) Place the column "after" another column (MySQL)
* @method $this always() Used as a modifier for generatedAs() (PostgreSQL)
* @method $this autoIncrement() Set INTEGER columns as auto-increment (primary key)
* @method $this change() Change the column
* @method $this charset(string $charset) Specify a character set for the column (MySQL)
* @method $this collation(string $collation) Specify a collation for the column (MySQL/PostgreSQL/SQL Server)
* @method $this comment(string $comment) Add a comment to the column (MySQL/PostgreSQL)
* @method $this default(mixed $value) Specify a "default" value for the column
* @method $this first() Place the column "first" in the table (MySQL)
* @method $this generatedAs(string|Expression $expression = null) Create a SQL compliant identity column (PostgreSQL)
* @method $this index(string $indexName = null) Add an index
* @method $this nullable(bool $value = true) Allow NULL values to be inserted into the column
* @method $this persisted() Mark the computed generated column as persistent (SQL Server)
* @method $this primary() Add a primary index
* @method $this spatialIndex() Add a spatial index
* @method $this startingValue(int $startingValue) Set the starting value of an auto-incrementing field (MySQL/PostgreSQL)
* @method $this storedAs(string $expression) Create a stored generated column (MySQL/PostgreSQL/SQLite)
* @method $this type(string $type) Specify a type for the column
* @method $this unique(string $indexName = null) Add a unique index
* @method $this unsigned() Set the INTEGER column as UNSIGNED (MySQL)
* @method $this useCurrent() Set the TIMESTAMP column to use CURRENT_TIMESTAMP as default value
* @method $this useCurrentOnUpdate() Set the TIMESTAMP column to use CURRENT_TIMESTAMP when updating (MySQL)
* @method $this virtualAs(string $expression) Create a virtual generated column (MySQL/PostgreSQL/SQLite)
*/
class ColumnDefinition extends Fluent
{
//
}
from laravel-migrations-generator.
Hello @AntonTalalaev
Thank you for reporting this issue.
I understand this is the actual behavior:
Schema::create('tabkeName', function (Blueprint $table) {
$table->timestamp('created_at')->default('now()');
$table->timestamp('updated_at')->default('now()');
});
What is the expected behavior?
Is it supported by any method mentioned in the doc?
https://laravel.com/docs/8.x/migrations#introduction
from laravel-migrations-generator.
Related Issues (20)
- php-enum version incompatible HOT 3
- Multiple Primary Keys defined HOT 3
- Please update PHP version to latest in composer.json file HOT 1
- Bug: Connection option doesn't work as expected HOT 6
- Inconsistent ordering in squashed migration HOT 4
- when generating migration i get SQLSTATE[42S22]: Column not found: 1054 Unknown column 'GENERATION_EXPRESSION' in 'field list' HOT 3
- log and migration path HOT 6
- Migrations try to recreate FKs even with table checks HOT 2
- Ignore vendor migrations HOT 1
- Argument 1 passed to KitLoong\MigrationsGenerator\Setting::setPath() must be of the type string HOT 2
- Support table and field-level charsets and collations HOT 3
- MySQL Error: Illegal mix of collations error when executing generating command HOT 4
- Config: ignore tables HOT 1
- Migrations for triggers
- Run from Controller HOT 3
- Create table migrations generated with wrong column types HOT 6
- php artisan migrate:generate ERROR HOT 1
- Error while using HOT 3
- Laravel 8 - MariaDB error when generating stored procedures migration HOT 1
- Custom postgres types fails if there is an index on the type HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-migrations-generator.