payment_methods table
The payment_methods table in the Reddit Clone Database Schema schema has 10 columns, keyed by id, with 1 foreign key to users. 1 column in orders references it.
Display fragments only. The card itself lives with the processor and this row holds a token, which is the difference between a schema you can run and one that drags PCI scope across the whole database.
Columns (10)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| user_id | uuid | not null, references users.id | |
| processor | varchar(40) | not null | |
| processor_token | varchar(255) | not null | |
| brand | varchar(40) | ||
| last4 | char(4) | ||
| exp_month | smallint | ||
| exp_year | smallint | ||
| is_default | boolean | not null | |
| created_at | timestamptz | not null |
Indexes (1)
(user_id, is_default)
Relationships
payment_methods.user_idreferencesusers.idorders.payment_method_idreferencespayment_methods