Giter Site home page Giter Site logo

kitloong / laravel-migrations-generator Goto Github PK

View Code? Open in Web Editor NEW
2.4K 42.0 266.0 1.17 MB

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

License: MIT License

PHP 100.00%
laravel existing-database lumen database-migrations migrations

laravel-migrations-generator's Introduction

Laravel Migrations Generator

Style check CI Tests CI codecov Latest Stable Version Total Downloads License

Generate Laravel Migrations from an existing database, including indexes and foreign keys!

This package is a modified version of https://github.com/Xethron/migrations-generator that has been updated to support Laravel 5.6 and beyond, along with additional features.

Supported Database

Laravel Migrations Generator supports all five Laravel first-party support databases:

  • MariaDB
  • MySQL
  • PostgreSQL
  • SQL Server
  • SQLite

Version Compatibility

Laravel Version
11.x 7.x
>= 10.43.x 7.x
10.x | <= 10.42.x 6.x
9.x 6.x
8.x 6.x
7.x 6.x
6.x 6.x
5.8.x 6.x
5.7.x 6.x
5.6.x 6.x
<= 5.5.x https://github.com/Xethron/migrations-generator

Install

The recommended way to install this is through composer:

composer require --dev kitloong/laravel-migrations-generator

Laravel Setup

Laravel will automatically register service provider for you.

Lumen Setup

Expand

Auto-discovery is not available in Lumen, you need some modification on bootstrap/app.php.

Enable Facade

Uncomment the following line.

$app->withFacades();

Register Provider

Add following line into the Register Service Providers section.

$app->register(\KitLoong\MigrationsGenerator\MigrationsGeneratorServiceProvider::class);

Usage

To generate migrations from a database, you need to have your database setup in Laravel's config (config/database.php).

To create migrations for all the tables, run:

php artisan migrate:generate

You can specify the tables you wish to generate using:

php artisan migrate:generate --tables="table1,table2,table3,table4,table5"

You can also ignore tables with:

php artisan migrate:generate --ignore="table3,table4,table5"

Laravel Migrations Generator will first generate all the tables, columns and indexes, and afterwards setup all the foreign key constraints.

So make sure you include all the tables listed in the foreign keys so that they are present when the foreign keys are created.

You can also specify the connection name if you are not using your default connection with:

php artisan migrate:generate --connection="connection_name"

Squash Migrations

By default, Generator will generate multiple migration files for each table.

You can squash all migrations into a single file with:

php artisan migrate:generate --squash

Options

Run php artisan help migrate:generate for a list of options.

Options Description
-c, --connection[=CONNECTION] The database connection to use
-t, --tables[=TABLES] A list of tables or views you wish to generate migrations for separated by a comma: users,posts,comments
-i, --ignore[=IGNORE] A list of tables or views you wish to ignore, separated by a comma: users,posts,comments
-p, --path[=PATH] Where should the file be created?
-tp, --template-path[=TEMPLATE-PATH] The location of the template for this generator
--date[=DATE] Migrations will be created with specified date. Views and foreign keys will be created with + 1 second. Date should be in format supported by Carbon::parse
--table-filename[=TABLE-FILENAME] Define table migration filename, default pattern: [datetime]\_create_[name]_table.php
--view-filename[=VIEW-FILENAME] Define view migration filename, default pattern: [datetime]\_create_[name]_view.php
--proc-filename[=PROC-FILENAME] Define stored procedure filename, default pattern: [datetime]\_create_[name]_proc.php
--fk-filename[=FK-FILENAME] Define foreign key migration filename, default pattern: [datetime]\_add_foreign_keys_to_[name]_table.php
--log-with-batch[=LOG-WITH-BATCH] Log migrations with given batch number. We recommend using batch number 0 so that it becomes the first migration
--default-index-names Don't use DB index names for migrations
--default-fk-names Don't use DB foreign key names for migrations
--use-db-collation Generate migrations with existing DB collation
--skip-log Don't log into migrations table
--skip-vendor Don't generate vendor migrations
--skip-views Don't generate views
--skip-proc Don't generate stored procedures
--squash Generate all migrations into a single file
--with-has-table Check for the existence of a table using hasTable

SQLite Alter Foreign Key

The generator first generates all tables and then adds foreign keys to existing tables.

However, SQLite only supports foreign keys upon creation of the table and not when tables are altered. add_foreign_keys migrations will still be generated, however will get omitted if migrate to SQLite type database.

User-Defined Type Columns

The generator will recognize user-defined type from the schema, and then generate migration as

public function up()
{
    Schema::create('table', function (Blueprint $table) {
        ...
    });
    DB::statement("ALTER TABLE table ADD column custom_type NOT NULL");
}

Note that the new column is always added at the end of the created table which means the ordering of the column generated in migration will differ from what we have from the schema.

Supported database with user-defined types:

  • PostgreSQL
  • SQL Server

Thank You

Thanks to Bernhard Breytenbach for his great work. This package is based on https://github.com/Xethron/migrations-generator.

Contributors

Contributors

License

The Laravel Migrations Generator is open-sourced software licensed under the MIT license

laravel-migrations-generator's People

Contributors

acidjazz avatar ahmadsyamim avatar akalongman avatar assertchris avatar bktz avatar chrishepner avatar crysglodzienski avatar edwinvanegmond avatar glodzienski avatar gpibarra avatar hming avatar imanghafoori1 avatar kitloong avatar kkszymanowski avatar ldebrouwer-rmn avatar niyiojeyinka avatar pablorsk avatar peeto avatar roboroads avatar sebdesign avatar shadywallas avatar shemgp avatar spescina avatar tiifuchs avatar tomzx avatar tucker-eric avatar viral-vector avatar virtualize avatar xethron avatar yasming avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-migrations-generator's Issues

Fatal throwable error on generate

Hi,
I'm on laravel 6 and after installing the package with composer and running php artisan migrate:generate i get this error
Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to MigrationsGenerator\MigrationsGeneratorSetting::setTableFilename() must be of the type string, null given, called in C:\lar agon\www\erp\vendor\kitloong\laravel-migrations-generator\src\MigrationsGenerator\MigrateGenerateCommand.php on line 116

Question, how to change the mapping array of integers to text?

Thanks for the package and keep it maintained
In postgres sql, currently array of integer is mapped to integer,
may i know why it was mapped to integer, even if it's updated to text it was fine, but why as integer? any particular reason for that,
though if i want to change the mapping to text how could i do that? any config changes need to applied

Providing `spatialIndex` parameters although it shouldn't receive any parameters

The package generates a migration file with spatial indexes and passes an index name as a parameter, although spatialIndex shouldn't receive any parameters.

<?php

// Current:
$table->point('location')->spatialIndex('apartments_location_spatial');

// Should be:
$table->point('location');
$table->spatialIndex('location', 'apartments_location_spatial');

Need virtual column support

Original migration:

Schema::create('voucher', function (Blueprint $table) {
     $table->increments('id');
    $table->unsignedDecimal('money')->nullable()->virtualAs('`config`->>"$.money"');
    $table->json('config')->nullable();
    $table->timestamps();
});

To MySQL:

CREATE TABLE `pro_voucher` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `money` decimal(8,2) unsigned GENERATED ALWAYS AS (json_unquote(json_extract(`config`,'$.money'))) VIRTUAL,
    `config` json DEFAULT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL,
);

Generate:

Schema::create('voucher', function (Blueprint $table) {
    $table->increments('id');
    $table->decimal('money')->unsigned()->nullable();
    $table->json('config')->nullable();
    $table->timestamps();
});

This component not support virtual column in mysql. It seem like not easy to implement, but if someone did that will be great!

Timestamp like `created_at` with default value `now()` generated with actual (fixed) timeasamp as a default value

DB: postgres

Existing table structure:

Column Type Collation Nullable Default
created_at timestamp(0) without time zone not null now()
updated_at timestamp(0) without time zone not null now()

Generated table structure:

Column Type Collation Nullable Default
created_at timestamp(0) without time zone not null '2021-06-21 19:30:05.997451'::timestamp without time zone
updated_at timestamp(0) without time zone not null '2021-06-21 19:30:05.997451'::timestamp without time zone

Generated migration:

Schema::create('tabkeName', function (Blueprint $table) {
            $table->timestamp('created_at')->default('now()');
            $table->timestamp('updated_at')->default('now()');
        });

Error during migrate:generate of custom data type in postgres 13.

Ran this command after installing the package:

php artisan migrate:generate -c pgsql

We have custom data type for some columns in postgres 13.
example:

create type phone_number_type as enum ('TOLL-FREE', 'SHORTCODE', '10 DLC', 'ALPHANUMERIC', 'TOLLFREE');

Then used in table like this:

create table phone_numbers
(
    id          bigserial
        constraint phone_numbers_pk primary key,
    phone       varchar(60),
    type        phone_number_type,
);

This package gives following error during migration generate:
image

SQLite Database

Please, how can I generate migrations from a SQLite database ?
I installed the package, but when I run the command php artisan migrate:generate, I get this error: Undefined index: SQLite

Type enum already exists

I'm getting an Type enum already exists exception when trying to execute migrate:generate and don't fully understand, what I'm missing here. See (truncated) stacktrace below.

php artisan migrate:generate -vvv
Using connection: mysql


   Doctrine\DBAL\DBALException

  Type enum already exists.

  at vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:254
    250|      * @return \Doctrine\DBAL\DBALException
    251|      */
    252|     public static function typeExists($name)
    253|     {
  > 254|         return new self('Type ' . $name . ' already exists.');
    255|     }
    256|
    257|     /**
    258|      * @param string $name

  1   vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/TypeRegistry.php:68
      Doctrine\DBAL\DBALException::typeExists("enum")

  2   vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php:246
      Doctrine\DBAL\Types\TypeRegistry::register("enum", Object(KitLoong\MigrationsGenerator\Types\EnumType))

  3   vendor/kitloong/laravel-migrations-generator/src/KitLoong/MigrationsGenerator/Generators/SchemaGenerator.php:90
      Doctrine\DBAL\Types\Type::addType("enum", "KitLoong\MigrationsGenerator\Types\EnumType")

  4   vendor/kitloong/laravel-migrations-generator/src/Xethron/MigrationsGenerator/MigrateGenerateCommand.php:132
      KitLoong\MigrationsGenerator\Generators\SchemaGenerator::initialize("mysql")

Option for single file generation

Would love to see an option for generating a single file with all migration data. One file per table, and another for foreign keys, is a lot of files!

Full Text Index not recognised

Great module, really useful thank you.

A Full Text index though is created as a regular index which throws an error when trying to index a TEXT field

Not sure if laravel has a method so I normally create a direct command to make them:-

DB::statement('ALTER TABLE faqsADD FULLTEXTfull_text (question, answer);');

MySQLRepository uppercase property error

Hello,
while trying to generate migrations i got an error

Undefined property: stdClass::$Type at D:\Dev\wikitaf\vendor\kitloong\laravel-migrations generator\src\KitLoong\MigrationsGenerator\Repositories\MySQLRepository.php:22

The problem seems to be the Type property on MySQLRepository::getSetPresetValues and MySQLRepository::getEnumPresetValues

Replacing by type (without uppercase) works fine for me.

package version : "^4.4",

image

Unable to generate Postgres migrations when using --connection

When trying to generate a migration for a table in the non-default connection no output is generated.

I am trying to generate migrations from an AWS Redshift database. Regular queries on a separate connection (named redshift) execute without issue. When I specify that connection for this command, nothing gets written to disk.

The one clue I have to go on is that no tablename is shown in the message that gets output. There are strings of text that should contain table names, but they are empty

Error on Generate: Call to private Doctrine\DBAL\Types\Type::__construct() from context 'MigrationsGenerator\DBAL\Schema'

System

Laravel 8, php 7.3.7, laravel-migrations-generator 5.1, MySQL MariaDB 10.2 image from docker

Issue Description

Error thrown on php artisan migrate:generate

php artisan migrate:generate

   Error 

  Call to private Doctrine\DBAL\Types\Type::__construct() from context 'MigrationsGenerator\DBAL\Schema'

  at vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/DBAL/Schema.php:220
    216▕      * @throws \Doctrine\DBAL\Exception
    217▕      */
    218▕     protected function registerCustomDoctrineType(string $dbType, string $class): void
    219▕     {
  ➜ 220▕         $doctrineType = (new $class())->getName();
    221▕         if (!Type::hasType($doctrineType)) {
    222▕             Type::addType($doctrineType, $class);
    223▕         } else {
    224▕             Type::overrideType($doctrineType, $class);

      +15 vendor frames
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Expected behaviour

Generate migrations for my database

Stack trace

[2022-01-24 20:35:14] local.ERROR: Call to private Doctrine\DBAL\Types\Type::__construct() from context 'MigrationsGenerator\DBAL\Schema' {"exception":"[object] (Error(code: 0): Call to private Doctrine\\DBAL\\Types\\Type::__construct() from context 'MigrationsGenerator\\DBAL\\Schema' at /app/vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/DBAL/Schema.php:220)
[stacktrace]
#0 /app/vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/DBAL/Schema.php(91): MigrationsGenerator\\DBAL\\Schema->registerCustomDoctrineType('double', 'MigrationsGener...')
#1 /app/vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/MigrateGenerateCommand.php(79): MigrationsGenerator\\DBAL\\Schema->initialize()
#2 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): MigrationsGenerator\\MigrateGenerateCommand->handle()
#3 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#4 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#5 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#6 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#7 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call(Array)
#8 /app/vendor/symfony/console/Command/Command.php(298): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#9 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#10 /app/vendor/symfony/console/Application.php(1005): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#11 /app/vendor/symfony/console/Application.php(299): Symfony\\Component\\Console\\Application->doRunCommand(Object(MigrationsGenerator\\MigrateGenerateCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#12 /app/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#13 /app/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#14 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#15 /app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#16 {main}
"} 

The tool is generating a Table instance for every table in the database even if they are not requested

Since version 5, we are getting RAM-related errors because the tool is trying to instantiate a Table class for each table in our database. Normally, I guess, that should not be a problem. But we have some databases with more than 50k tables and views.

I'm specifying which tables should be generated (less than 100), but I noticed in the code of the tool that it first (1) gets the names of all the tables of the database, then (2) it gets the "details" of each of them, one by one, and finally (3) it filters the tables according to what we specify in the command's parameters.

Shouldn't step 3 happen before step 2 so it only the details of the tables we specified?

In version 4, we didn't have this problem.

For reference, this is the method that does the "get the tables and filter them" job.

error in postgres timestamp column

Hi
when I use timestamp column in my table and generate migration, I get an error:


TypeError 

  Argument 1 passed to MigrationsGenerator\Support\Regex::getTextBetween() must be of the type string, null given, called in C:\xampp\htdocs\console\doc\vendor\kitloong\laravel-migrations-generator\src\Mi
grationsGenerator\Generators\Columns\DatetimeColumn.php on line 133

  at C:\xampp\htdocs\console\doc\vendor\kitloong\laravel-migrations-generator\src\MigrationsGenerator\Support\Regex.php:15
     11▕      * @param  string  $left  Left tag.
     12▕      * @param  string  $right  Right tag.
     13▕      * @return string|null
     14▕      */
  ➜  15▕     public function getTextBetween(string $text, string $left = '\(', string $right = '\)'): ?string
     16▕     {
     17▕         $matched = preg_match('/'.$left.'(.*?)'.$right.'/', $text, $output);
     18▕         if ($matched === 1) {
     19▕             return $output[1];

  1   C:\xampp\htdocs\console\doc\vendor\kitloong\laravel-migrations-generator\src\MigrationsGenerator\Generators\Columns\DatetimeColumn.php:133
      MigrationsGenerator\Support\Regex::getTextBetween()

  2   C:\xampp\htdocs\console\doc\vendor\kitloong\laravel-migrations-generator\src\MigrationsGenerator\Generators\Columns\DatetimeColumn.php:112
      MigrationsGenerator\Generators\Columns\DatetimeColumn::getPgSQLLength("console.apps", Object(Doctrine\DBAL\Schema\Column))

How to use it in production

If I already have 10 migrations but I want to regenerate all according to the database so when I setup new env to be ready but also want to not screw up the production database?

Postgres bool field default value wrong

A bool field in PostgreSQL database with default value doesn't turn to proper migration:

Is:
$table->boolean('create')->default(''); // when default is false
$table->boolean('create')->default('1'); // when default is true

Should be:
$table->boolean('create')->default(false); // when default is false
$table->boolean('create')->default(true); // when default is true

Return value of MigrationsGenerator\MigrationsGeneratorSetting::getTableFilename() must be of the type string, null returned

I am having the upper mentioned error even after trying multiple time but still it is not working. Anyway, here is the steps I followed and got this error.

First I run this command line.
composer require --dev "kitloong/laravel-migrations-generator"

Then edit app.php file and added the below code to register this.

'providers' => [
    ..................
    \MigrationsGenerator\MigrationsGeneratorServiceProvider::class,
  ],

Then run the below code as I have many connections to different database in my database.php. MY localhost connection is labeled as localhost also as I want to generate migrations for my localhost database tables only.
php artisan migrate:generate --connection="localhost"

Now after doing all above, I got the below error...

$ php artisan migrate:generate --connection="localhost"
In MigrationsGeneratorSetting.php line 225:
Return value of MigrationsGenerator\MigrationsGeneratorSetting::getTableFilename() must be of the type string, null returned

Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6"

vendor/kitloong/laravel-migrations-generator/src/KitLoong/MigrationsGenerator/MigrationsGeneratorSetting.php:63

protected function getDoctrineDriver()
64| {
65| if (! class_exists(DoctrineDriver::class)) {

66| throw new LogicException(
67| 'Laravel v6 is only compatible with doctrine/dbal 2, in order to use this feature you must require the package "doctrine/dbal:^2.6".'
68| );
69| }

can't install this package on Laravel Framework 5.8.37

Trying to istall this package on Laravel Framework 5.8.37 by running
composer require --dev "kitloong/laravel-migrations-generator"

but i've got this:

Using version ^4.3 for kitloong/laravel-migrations-generator
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove laravel/framework v5.8.37
    - Conclusion: don't install laravel/framework v5.8.37
    - way/generators 2.0 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[4.1.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - way/generators 2.1 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[4.1.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - way/generators 2.2 requires illuminate/support 4.1.* -> satisfiable by illuminate/support[4.1.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9].
    - way/generators 2.3 requires illuminate/support ~4.1 -> satisfiable by illuminate/support[4.1.x-dev, 4.2.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, 
v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0-BETA1, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - way/generators 2.4 requires illuminate/support ~4.1 -> satisfiable by illuminate/support[4.1.x-dev, 4.2.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, 
v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0-BETA1, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - way/generators 2.5 requires illuminate/support ~4.1 -> satisfiable by illuminate/support[4.1.x-dev, 4.2.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, 
v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0-BETA1, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - way/generators 2.6 requires illuminate/support ~4.1 -> satisfiable by illuminate/support[4.1.x-dev, 4.2.x-dev, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, 
v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0-BETA1, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - way/generators 2.6.1 requires illuminate/support ~4.0 -> satisfiable by illuminate/support[4.0.x-dev, 4.1.x-dev, 4.2.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.0-BETA1, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - don't install illuminate/support 4.1.x-dev|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.0|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.1|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.10|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.11|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.12|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.13|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.14|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.15|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.16|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.17|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.18|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.19|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.2|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.20|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.21|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.22|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.23|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.24|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.25|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.26|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.27|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.28|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.29|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.3|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.30|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.4|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.5|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.6|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.7|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.8|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.1.9|don't install laravel/framework v5.8.37
    - don't install illuminate/support 4.2.x-dev|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.0-BETA1|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.1|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.12|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.16|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.17|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.2|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.3|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.4|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.5|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.6|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.7|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.8|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.2.9|don't install laravel/framework v5.8.37
    - don't install illuminate/support 4.0.x-dev|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.0|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.0-BETA2|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.0-BETA3|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.0-BETA4|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.1|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.10|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.2|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.3|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.4|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.5|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.6|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.7|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.8|don't install laravel/framework v5.8.37
    - don't install illuminate/support v4.0.9|don't install laravel/framework v5.8.37
    - Installation request for laravel/framework (locked at v5.8.37, required as 5.8.*) -> satisfiable by laravel/framework[v5.8.37].
    - Installation request for way/generators ~2.0 -> satisfiable by way/generators[2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.6.1].


Installation failed, reverting ./composer.json to its original content.

Incorrectly mapping tinyint(1) to boolean

There appears to be a bad assumption made here that just because Laravel maps boolean to MySQL tinyint(1), that ALL occurrences of tinyint(1) in the database should be mapped back to boolean in the migration files.

Tinyints can represent any signed value between -128 and 127, and people use it as such. They should NOT be mapped back to boolean.

Migrations generated for another connection are logged in the wrong connection

Hello,

Current behaviour

When you generate migrations for another connection, and chose to log these migrations in the migrations table, they are logged in the migrations table of the other connection.

Expected behaviour

When you generate migrations for another connection, and chose to log these migrations in the migrations table, they should be logged in the migrations table of the default connection. (This is actually what happens when you run the php artisan migrate command for a migration related to a connection that is not the default one.)

I use the 7.0 version of laravel/framework.

Thank you!

Timestamps problem

  • users table
CREATE TABLE `users`  (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '姓名1,
  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
  • exec generate
$ php artisan migrate:generate users
  • migration file
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id')->comment('ID');
            $table->timestamps()->comment('更新时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

$table->timestamps()->comment('更新时间');This line raises an error while performing the migration.Because it has no comment method.Hope you can help, thank you very much!

Path is not working

Hi, first of all I want to thank you for this awesame package!!

I have a small issue when running a command with the --path option and it always throws the following error:

php artisan migrate:generate --path="testing"

 ErrorException 

  file_put_contents(./testing/2021_02_10_170030_create_accion_comparables_table.php): failed to open stream: No such file or directory

  at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:135


My goal is to create the migrations on a different folder than migrations, it can be a subfolder as well, do you know if i´m doing something wrong?

Thanks in advance,
Alejandro

Argument 1 passed to Doctrine\DBAL\Connection::ensureForwardCompatibilityStatement() must be an instance of Doctrine\DBAL\Driver\ResultStatement, instance of PDOStatement given

I have the an error when i run php artisan migrate:generate

error info: Argument 1 passed to Doctrine\DBAL\Connection::ensureForwardCompatibilityStatement() must be an instance of Doctrine\DBAL\Driver\ResultStatement, instance of PDOStatement given, called in myproject\ven
dor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php on line 1313, anyone konw How to solve it?

Need the support of enum / custom type

Database connection: pgsql

In the following scenario-

create type my_status as enum ('PENDING', 'ACTIVE', 'SUSPENDED');
create table mydb.mytable
(
	...
	status my_status not null,
	...
);

getting the following exception-

Unknown database type my_status requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may not support it.
~\vendor\doctrine\dbal\src\Platforms\AbstractPlatform.php:394

where is generated files?

after using the generating command i can't see them into migrations folder. where are them?

root@8680ab6ed9cd:/var/www# php artisan migrate:generate
Using connection: mysql

Generating migrations for: 

 Do you want to log these migrations in the migrations table? [Y/n] :
 > n

Setting up Tables and Index Migrations

Setting up Foreign Key Migrations


Finished!

migrations folder is empty. database connection and my .env file is correct because i'm using that now

TypeError on generate migration files

database.php

'rwsn_sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL_RWSN_SQLSRV'),
            'host' => env('DB_HOST_RWSN_SQLSRV', 'localhost'),
            'port' => env('DB_PORT_RWSN_SQLSRV', '1433'),
            'database' => env('DB_DATABASE_RWSN_SQLSRV', 'forge'),
            'username' => env('DB_USERNAME_RWSN_SQLSRV', 'forge'),
            'password' => env('DB_PASSWORD_RWSN_SQLSRV', ''),
            'schema' => env('DB_SCHEMA_RWSN_SQLSRV', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],

php artisan migrate:generate -c rwsn_sqlsrv

Using connection: rwsn_sqlsrv


   TypeError 

  MigrationsGenerator\DBAL\Mapper\ViewMapper::makeView(): Argument #2 ($sql) must be of type string, null given, called in /var/www/html/server/niyam/vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/DBAL/Mapper/ViewMapper.php on line 60

  at vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/DBAL/Mapper/ViewMapper.php:77
     73▕ 
     74▕     /**
     75▕      * @throws \Doctrine\DBAL\Exception
     76▕      */
 77    private static function makeView(string $name, string $sql): View
     78▕     {
     79▕         // trim quotes
     80▕         $unquotedName = str_replace(['`', '"', '[', ']'], '', $name);
     81▕ 

      +3 vendor frames 
  4   [internal]:0
      MigrationsGenerator\DBAL\Schema::MigrationsGenerator\DBAL\{closure}()

      +18 vendor frames 
  23  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Remote deployment (Forge / Deployer) not possible

Heya and thanks for this awesome piece of code!

We have one issue: We're using Laravel Forge or Deployer (both pull the code from a git repo on the remote server) in our projects and this leads to errors when we ran the migrations generator locally, commit and push the changes and then deploy.

Because the remote server does not have the locally generated entries for the new migrations in the migrations table, the required php artisan migrate command fails (SQLSTATE[42S01]: Base table or view already exists).

Any idea how to work around this issue?

Thanks in advance!

Pelle

There's a way to generate a migration from *.sql file?

There's a way to generate a migration from *.sql file?

I was reading the documentation, and couldn't an answer for this.
I don't want to generate it from a connection, but from an SQL file, can I do it maybe using one of yours classes?

What about a data option?

First of all, you made a great work!
What about a data option? The idea is to add a -d option that permit to generate a migation file with the data present in the table. A suggest wpuld be:

    public function up()
    {
        Schema::create('myTable', function (Blueprint $table) {
            $table->id();
            // others fields
        });

        $data = [
            ["id" => 1, "field_1" => "value_1", /* ...*/  "type" => "field_n" => "value_n"],
            ["id" => 2, "field_1" => "value_1", /* ...*/  "type" => "field_n" => "value_n"],
            /*...*/
            ["id" => n, "field_1" => "value_1", /* ...*/  "type" => "field_n" => "value_n"]
        ];
        DB::table('myTable')->insert($data);
    }

I hope you think it's an interesting idea

MySQL 8 compability

MySQL 8 is already here, it would be awesome If it was supported, I do not know if is the version but I couldn't make migration from MySQL 8, it works perfectly from a Seventh version.

Error generating migrations for specific tables

Framework: Laravel 8.7.1

Issue Error generating Migrations for specific tables comma separated

Command: php artisan migrate:generate --tables= "table1,table2"

Stack Trace:

TypeError 

  Argument 1 passed to MigrationsGenerator\MigrationsGeneratorSetting::setTableFilename() must be of the type string, null given, called in /home/username/Projects/project_name/vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/MigrateGenerateCommand.php on line 123

  at vendor/kitloong/laravel-migrations-generator/src/MigrationsGenerator/MigrationsGeneratorSetting.php:233
    229▕ 
    230▕     /**
    231▕      * @param  string  $tableFilename
    232▕      */
  ➜ 233▕     public function setTableFilename(string $tableFilename): void
    234▕     {
    235▕         $this->tableFilename = $tableFilename;
    236▕     }
    237▕ 

      +15 vendor frames 
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()


...

First, following the installation steps, at the bootstrap/app.php there isn't a line that has $app->withFacades(); commented.
If I add $app->withFacades(); it shows up an error, so if I only add $app->register(\KitLoong\MigrationsGenerator\MigrationsGeneratorServiceProvider::class); this error shows up:
PHP Fatal error: Uncaught ReflectionException: Class config does not exist in path/to/project/vendor/laravel/framework/src/Illuminate/Container/Container.php:830

Procedure support

Can procedure support be added? I am sure it will make the project much more useful.

FATAL erreur lors de l'installation sur LARAVEL 8

bonjour, lorsque je mets la commande php artisan migrate:generate voici l'erreur affichée (ci-dessous). pouvez vous m'aider ?
de plus dans bootstrap/app.php $app->withFacades(); n'est pas accepté !

Fatal error: Uncaught ReflectionException: Class config does not exist in C:\wampServer64\www\LARAVEL\FdR_TP1_Laravelinititaion\TPJqueryDatatable\vendor\laravel\framework\src\Illumin
ate\Container\Container.php:830
Stack trace:
#0 C:\wampServer64\www\LARAVEL\FdR_TP1_Laravelinititaion\TPJqueryDatatable\vendor\laravel\framework\src\Illuminate\Container\Container.php(830): ReflectionClass->__construct('config'
)
#1 C:\wampServer64\www\LARAVEL\FdR_TP1_Laravelinititaion\TPJqueryDatatable\vendor\laravel\framework\src\Illuminate\Container\Container.php(712): Illuminate\Container\Container->build
('config')
#2 C:\wampServer64\www\LARAVEL\FdR_TP1_Laravelinititaion\TPJqueryDatatable\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(826): Illuminate\Container\Container->re
solve('config', Array, true)
#3 C:\wampServer64\www\LARAVEL\FdR_TP1_Laravelinititaion\TPJqueryDatatable\vendor\laravel\framework\src\Illuminate\Container\Container.php(651): Illuminate\Foundation\Application->re
solve('config', Array)
#4 C:\wampServer6 in C:\wampServer64\www\LARAVEL\FdR_TP1_Laravelinititaion\TPJqueryDatatable\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 832

Support for generating view and trigger

It will be awesome if have support to generating view and trigger from database.
I already have sample of those migration that already working in my project.

  1. This is migration for trigger looks like.
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTriggerDomainInsert extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::getPdo()->exec('
          CREATE TRIGGER domain_insert AFTER INSERT ON numbers FOR EACH ROW
            INSERT INTO number_domain_history (number_id, domain_name, date) VALUES (NEW.id, NEW.domain, NOW())
        ');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::getPdo()->exec('DROP TRIGGER `domain_insert`');
    }
}
  1. This is migration for view looks like.
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateViewNumberReport extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::statement("DROP VIEW IF EXISTS number_contact_report_view");

        DB::statement("
          CREATE VIEW number_contact_report_view AS (
            SELECT
              users.name AS user_name,
              cl.date,
              SUM(cl.deposit_amount) AS sum_deposit_amount,
              COUNT(contact_status_destination_id) AS total_status,
              CASE WHEN contact_status_destination_id = 1 THEN COUNT(contact_status_destination_id) END AS not_interested,
              CASE WHEN contact_status_destination_id = 2 THEN COUNT(contact_status_destination_id) END AS interested,
              CASE WHEN contact_status_destination_id = 3 THEN COUNT(contact_status_destination_id) END AS registered,
              CASE WHEN contact_status_destination_id = 4 THEN COUNT(contact_status_destination_id) END AS success,
              CASE WHEN contact_status_destination_id = 5 THEN COUNT(contact_status_destination_id) END AS trash
            FROM contact_logs AS cl
            LEFT JOIN contact_status AS cs ON cs.id = cl.contact_status_destination_id
            LEFT JOIN users ON users.id = cl.user_id
            GROUP BY user_name, contact_status_destination_id, cl.date
          )
        ");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::statement("DROP VIEW IF EXISTS number_contact_report_view");
    }
}

column pgc.consrc does not exist | postgresql version 13

Illuminate\Database\QueryException

SQLSTATE[42703]: Undefined column: 7 ERROR: column pgc.consrc does not exist
LINE 7: pgc.consrc AS definition
^
HINT: Perhaps you meant to reference the column "pgc.conkey" or the column "pgc.conbin". (SQL:
SELECT pgc.conname AS constraint_name,
pgc.contype,
ccu.table_schema AS table_schema,
ccu.table_name,
ccu.column_name,
pgc.consrc AS definition
FROM pg_constraint pgc
JOIN pg_namespace nsp ON nsp.oid = pgc.connamespace
JOIN pg_class cls ON pgc.conrelid = cls.oid
LEFT JOIN information_schema.constraint_column_usage ccu
ON pgc.conname = ccu.constraint_name
AND nsp.nspname = ccu.constraint_schema
WHERE contype ='c'
AND ccu.table_name='pgsql_radreplies'
AND ccu.column_name='username';
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.