Comments (4)
Wow, awesome! Thanks so much for all the work you've done.
from openrecord.
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.
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
bigint
s (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 bigint
s (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.
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)
- Add documentation or examples to use with ldap HOT 4
- Publish a new release with latest dependency HOT 2
- How can i make raw sql query? HOT 1
- RangeError: Maximum call stack size exceeded HOT 1
- How to select SQL? HOT 2
- select_value as in activerecord HOT 12
- Please update CONTRIBUTING.md HOT 1
- Not returning complete record on create HOT 2
- How can one import/require the ValidationError class? HOT 1
- Help Wanted. Database query builder HOT 2
- has many through HOT 4
- Model.find() with empty argument has an unexpected return HOT 2
- Bugs when using offset / limit HOT 5
- How to initialize records from raw rows? HOT 2
- VScode Intellisense for auto generated models HOT 2
- create(data) but get null HOT 2
- Model.create({}) and Model.new({}) autoAttributes = true HOT 11
- ID conversion problem HOT 9
- mysql socketPath HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openrecord.