Giter VIP home page Giter VIP logo

Comments (4)

nibarulabs avatar nibarulabs commented on June 12, 2024 1

Wow, awesome! Thanks so much for all the work you've done.

from openrecord.

PhilWaldmann avatar PhilWaldmann commented on June 12, 2024

Hi @nibarulabs,

you are totally right to use bigint for relations in Postgres.
At the moment there is shared code for migrations wich works in SQLite, MySQL, Postgres and Oracle. The easiest way to get started was to use integer and it seems that I totally forgot to add database specific rules to the migration layer.

I think what we need is a this.references('field_name, 'table_name', {opts...}) method to define relations. Which should also add foreign key constrains to the table.

What do you think?

from openrecord.

nibarulabs avatar nibarulabs commented on June 12, 2024

Hey, @PhilWaldmann thx for quick reply. :)

Totally understandable approach to getting it done and out there. I have run into a few minor issues regarding all this.

  • primary keys are created using integer
  • i have no access to a bigint data type when creating migration columns
  • and you are right, the references will also need some config for bigints (fk constraints sound good too)
  • the stampable plugin uses integers as well

That's not a ton of work, but it's still a list. I have found work arounds for all of these, so not the end of the world. This is a typical migration for me:

    this.createTable('users', function () {
        this.uuid('uuid');
        this.string('email', {unique: true});
        this.string('password');
        this.string('first_name');
        this.string('last_name');
        this.string('confirm_email_token');
        this.type('bigint', 'activated_ts');

        this.stampable();
    });

So, you can see where I force bigints (I use epoch timetamps quite a bit as well which have to be bigger than integer). I'm guessing an option for bigint to be used as the pk above would work. Somewhere. I'm kinda riffing now, but I'm sure you get the gist.

My project will be going live at the end of the month. This lib was honestly make or break and it's helped me get things over the finish line. Thanks again. 👍

from openrecord.

PhilWaldmann avatar PhilWaldmann commented on June 12, 2024

I've published a new version.
this.id('name') will now use bigint.
this.userstamp() will use id('creator_id') and id('updater_id')
where is now a dedicated bigint type

regarding references: I forgot that this feature is already implemented. See references option

And thanks for the nice feedback =)

from openrecord.

Related Issues (20)

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.