我正在将用 php 和 laravel 编写的 Web 应用程序重写为 JavaScript 堆栈。目前我正在重新设计数据库模式,似乎是 mysql 到 postgres。
我对以下 create table 命令的一些语法有点困惑
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->unique();
$table->unsignedInteger('user_id')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity');
});
}
根据我的理解,上面的 postgres 等效项是
create table sessions (
id text unique not null,
user_id int references users,
ip_address text,
user_agent text,
payload text,
last_activity integer
);
但是我不确定我是否正确翻译了 $table->string('ip_address', 45)->nullable(); ,因为我不确定 string('ip_address', 45 ) 正在做。
我对 potgres 的转换是否正确,或者我需要更改什么才能在 postgres create 命令中获得等效的内容?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号