I am working on rewriting a web app written in php
and laravel
to a JavaScript stack. At present I am working on reworking the db schema which seems to be mysql to postgres.
I am slightly confused with some of the syntax for the following create table
command
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');
});
}
From my understanding the postgres
equivalent for the above would be
create table sessions (
id text unique not null,
user_id int references users,
ip_address text,
user_agent text,
payload text,
last_activity integer
);
However I am not sure that I have translated $table->string('ip_address', 45)->nullable();
correctly as I am not sure what exactly string('ip_address', 45)
is doing.
Is my transformation to potgres correct or what do I need to change in order to have something equivalent in the postgres create command?