matte97p/laravel-postgresql-inherit

为postgresql表添加继承功能

2.7 2023-04-24 13:37 UTC

This package is not auto-updated.

Last update: 2024-09-24 19:20:30 UTC


README

Software License

为postgresql表添加继承功能

安装

PHP 8.0+Laravel 10.x 是必需的。

关于最新Laravel版本,请参阅之前的分支。

对于Laravel版本 10.x,运行以下命令通过composer安装此包:

composer require "matte97p/laravel-postgresql-inherit ~2.7"

一旦安装了PostgreSQL模式,您需要注册服务提供者。打开 config/app.php 文件,并在 providers 数组中添加以下内容。

RishiRamawat\PostgresSchema\PostgresqlSchemaServiceProvider::class,

用法

在使用postgresql数据库的迁移文件中,您可以使用新的方法 inherits()

Schema::create('cities', function(Blueprint $table) {
  $table->increments('id');
  $table->string('name');
  $table->double('population');
  $table->integer('altitude')->comment('In Feet');
});

Schema::create('capitals', function(Blueprint $table) {
    $table->string('state');
    // Make capitals table inherits all the columns of its parent table, cities
    $table->inherits('cities');
});