将标题重写为:将php laravel的sql代码转换为postgres格式
P粉252116587
P粉252116587 2024-01-16 13:47:34
[PHP讨论组]

我正在将用 phplaravel 编写的 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 命令中获得等效的内容?

P粉252116587
P粉252116587

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号