question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema generation enhancements

See original GitHub issue

Piccolo now has a command for generating a schema from an existing database.

piccolo schema generate

The current implementation doesn’t cover every possible edge case and database feature, so there’s room for improvement. For example:

Column defaults

Getting the defaults for a column, and reflecting them in the Piccolo column. For example, if the column has a default of 1 in the database, we want that to be reflected in the Piccolo schema as:

class MyTable(Table):
    my_column = Integer(default=1)

On Delete / On Update

The database values aren’t currently reflected in the ForeignKey column definitions.

class MyTable(Table):
    my_column = ForeignKey(on_delete=OnDelete.cascade)

Decimal precision

The precision of a decimal column in the database currently isn’t reflected in the Decimal column definitions.

class MyTable(Table):
    my_column = Decimal(digits=(5,2))

It’s a fairly beginner friendly feature to work on, because even though the code is fairly advanced, it’s completely self contained, and doesn’t require extensive knowledge of the rest of Piccolo.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:24 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
dantownsendcommented, Sep 26, 2021

@wmshort Yeah, it was just omitted because we didn’t have the reflection capabilities at the time.

1reaction
dantownsendcommented, Sep 25, 2021

@wmshort Good question - it looks like you can find ON DELETE and ON UPDATE here:

select * from information_schema.referential_constraints;

I found this gist on it:

https://gist.github.com/velosipedist/7250141

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standardized schema generation and data loading with JPA
JPA enables you to generate your DB schema, create SQL scripts that you can import in other tools and load an initial data...
Read more >
Schema Generation - Software AG Documentation
New features and enhancements. Before You Start, How to activate this plug-in and how to connect to the development server. Elements of Schema...
Read more >
How to Improve Software Productivity and Quality: Schema ...
Most efforts to improve programmer productivity and software quality fail to generate lasting gains. New languages, new project management ...
Read more >
Schema Versioning and Generations - iTwin.js
Minor schema upgrades are schema changes that don't break compatibility with applications written for the previous schema. Minor schema upgrades ...
Read more >
Make schema updates | Cloud Spanner
Make schema updates · In the Google Cloud console. Submit an ALTER TABLE command on the Write DDL statements page. · Using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found