Comments (8)
Unique constraints seem to have been added in the view when creating a new table but not in the update a column view or create a new column view. Would be very helpful to add this feature in those two views as well.
Note: I've included a few bugs around this as well in the following issue. supabase/supabase#592 (comment)
from postgres-meta.
Could it be possible to allow for uniqueness across multiple columns e.g. if you have a table for storing a user's contact details/socials where the columns look something like id (int), user_id (int, foreign key), type (varchar), value (varchar). In that case you'd want to have unique(user_id, type) as a constraint so it wouldn't be possible to add duplicate values for the same type of contact info.
In the UI there's already similar functionality for marking fields as part of the primary key using check boxes. Could it be possible to provide a similar UI for selecting values to be part of a unique constraint? The only downside to that approach would be that it'd only work for one unique constraint per table when I think postgres allows more than one.
from postgres-meta.
Here is a way to manually add a unique constraint on two columns:
- Open the SQL editor
- Click "New query"
- Add the following:
alter table mytable
add constraint unique_col1_col2 unique (col1, col2);
- Click "Run"
If there are any duplicate rows, you'll have to delete those first before the query will take effect.
from postgres-meta.
Hi! I was thinking of taking a stab at this for columns, but wasn’t exactly sure what interface would be desirable. I see there's already a few constraint options (like is_unique
) in https://github.com/supabase/postgres-meta/blob/develop/src/lib/PostgresMetaColumns.ts, so would this be about allowing a user to specify a generic definition as free text when creating a column?
from postgres-meta.
Yeah, in this case we want to start with something as generic as possible, then we can add more specific functionality for anything which isn't covered 👍
would love any contributions!
from postgres-meta.
UI stuff aside: yes, we can make constraints be defined on tables the same way e.g. policies and primary keys are. The idea for this feature is for it to be the solution for all kinds of table constraints, including primary keys and UNIQUE
s.
from postgres-meta.
UI stuff aside: yes, we can make constraints be defined on tables the same way e.g. policies and primary keys are. The idea for this feature is for it to be the solution for all kinds of table constraints, including primary keys and
UNIQUE
s.
I don't quite fully understand, is it planned to add an UI option to add unique constraints across multiple columns?
I'd also like to be able to do what @DocLabyrinth requests :)
from postgres-meta.
This repo is decoupled from the UI - the UI can do ad-hoc queries and thus can support multi-columns constraints, but ideally this would be handled from a dedicated endpoint (e.g. /constraints
).
from postgres-meta.
Related Issues (20)
- typescript generated type of pgvector/vector is string HOT 5
- Generate types for foreign tables HOT 5
- Generating types for a postgresql array results in Typescript unknown property HOT 4
- Feat: Indexes HOT 1
- supabase gen types generates duplicate identifiers HOT 3
- gentype producing wrong type for inner join HOT 1
- Typegen is not respecting unique table constraint HOT 3
- Permission denied error when generating types HOT 3
- SSL connection error with "PG_META_DB_SSL_ROOT_CERT" and "rejectUnauthorized" misconfiguration HOT 3
- Stopping the container is slow, resorting to SIGKILL
- How to get online postgre-meta version? HOT 1
- Generate types: "Json" type is incompatible with other types HOT 6
- Hardcoded metadata resulting in broken TypeScript type generation from the Supabase CLI HOT 1
- sslmode=require ignored on postgresql URL with gen types --db-url HOT 3
- Gen type throws an exception when table has no columns HOT 2
- Type generation script does not pick up correct type when a SQL function returns data from other table HOT 1
- Composite types can be null
- Generated DB types do not include function property in Table HOT 1
- Generating types in python format HOT 3
- [typescript gen] Add `CompositeTypes` helper HOT 2
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 postgres-meta.