schema_dart 0.0.5 copy "schema_dart: ^0.0.5" to clipboard
schema_dart: ^0.0.5 copied to clipboard

Generate dart type definitions from PostgreSQL database schema.

schema-dart #

Generate dart type definitions from PostgreSQL database schema (MVP)

Installation: #

The package can be installed as follow:

[~] dart pub global activate schema_dart
copied to clipboard

Usage: #

Within a dart/flutter project directory, you can run one of the following examples:

  • generate data classes for public schema (default)

    schema-dart -c postgresql://postgres:postgres@localhost:54322/postgres -o path/to/output/directory
    
    copied to clipboard
  • generate for data classes for a "cms" schema

    schema-dart -c <connection-string> -o <output-dir> -s cms
    
    copied to clipboard
  • generate data classes for specific tables from public schema (format sensitive):

    schema-dart -c <connection-string> -o <output-dir> -t "users","posts"
    
    copied to clipboard

    or

    schema-dart -c <connection-string> -o <output-dir> --schema=api --tables="profiles","posts"
    
    copied to clipboard

Note

if you receive the following error:

Severity.error Server does not support SSL, but it was required.
copied to clipboard

you can pass --no-ssl flag such as (not recommended):

schema-dart --no-ssl -c  <connection-string> -o <output-dir> 
copied to clipboard

All usage information:

Generate Data Classes for PostgreSQL schema
  
Examples: 

  # generate data classes for public schema (default)
  schema-dart -c postgresql://postgres:postgres@localhost:54322/postgres -o path/to/output/directory

  # generate for data classes for a "cms" schema 
  schema-dart -c <connection-string> -o <output-dir> -s cms

  # generate data classes for specific tables from public schema (format sensitive): 
  schema-dart -c <connection-string> -o <output-dir> -t "users","posts"
  # or
  schema-dart -c <connection-string> -o <output-dir> --schema=api --tables="profiles","posts"
  

Usage: schema-dart <command> [arguments]

Global options:
-h, --help                 Print this usage information.
-c, --connection-string    PostgreSQL connection string in the following format:
                           postgresql://<username>:<password>@<host>:<port>/<database-name>
-o, --output-dir           The output directory for the generated dart files
-s, --schema               specify the schema
                           (defaults to "public")
-t, --tables=<String>      provide a specific list of tables to generate data classes for.
                           (defaults to all tables)
    --no-ssl               Disable SSL for postgres connection (not recommended)
-n, --nullable-fields      When provided, all fields in generated class will be nullable (useful for partial table queries and for local table construction update/insert)
-i, --nullable-ids         When provided, columns that are identity & have identity generations will be generated as nullable fields
-d, --nullable-defaults    When provided, identity columns that have default values will be generated as nullable fields
-v, --verbose              Enable verbose logging.
    --version              Print the current version.

Available commands:
  help   Display help information for schema-dart.

Run "schema-dart help <command>" for more information about a command.
copied to clipboard

Sample Output: #

The following folder: example/sample_output contains a sample output from Supabase's auth schema.

11
likes
140
points
71
downloads

Publisher

verified publisherosaxma.com

Weekly Downloads

2024.07.10 - 2025.01.22

Generate dart type definitions from PostgreSQL database schema.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

args, built_collection, cli_util, code_builder, dart_style, docker_process, meta, path, postgres

More

Packages that depend on schema_dart