Entity subscription
Subject areas: Billing
Attributes
| # | Name | Type | Null | Default | Key | Terms | Description |
|---|---|---|---|---|---|---|---|
| 1 | id | bigint | no | PK | |||
| 2 | tenant_id | domain tenant_ref (bigint) | yes | FK | |||
| 3 | plan_id | bigint | no | FK | |||
| 4 | status | enum subscription_status | no | "trialing" | |||
| 5 | started_on | date | no | ||||
| 6 | ends_on | date | yes |
Keys
| Kind | Name | Attributes |
|---|---|---|
| primary | pk_subscription | id |
Relationships
| Name | Role | Other entity | Cardinality | Attributes | Identifying | On delete | On update |
|---|---|---|---|---|---|---|---|
| invoice_subscription | parent | invoice | one to many | invoice.subscription_id -> subscription.id | no | no_action | no_action |
| subscription_plan | child | plan | one to many | subscription.plan_id -> plan.id | no | restrict | no_action |
| subscription_tenant | child | tenant | one to many | subscription.tenant_id -> tenant.id | no | cascade | no_action |
Physical
lite (sqlite): main.subscription
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
|---|---|---|---|---|---|---|---|---|
| 1 | id | integer | no | by_default | id | |||
| 2 | tenant_id | integer | no | tenant_id | ||||
| 3 | plan_id | integer | no | plan_id | ||||
| 4 | status | text | no | "trialing" | status | |||
| 5 | started_on | text | no | started_on | ||||
| 6 | ends_on | text | yes | ends_on |
- primary key pk_subscription (id)
- check ck_subscription_status status IN ('trialing', 'active', 'past_due', 'cancelled')
- foreign key fk_subscription_plan (plan_id) references plan (id) on delete restrict
- foreign key fk_subscription_tenant (tenant_id) references tenant (id) on delete cascade
- index ix_subscription_plan (plan_id)
- index ix_subscription_tenant (tenant_id)
pg (postgresql): app.subscription
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
|---|---|---|---|---|---|---|---|---|
| 1 | id | bigint | no | always | id | |||
| 2 | tenant_id | bigint | no | tenant_id | ||||
| 3 | plan_id | bigint | no | plan_id | ||||
| 4 | status | subscription_status | no | "trialing" | status | |||
| 5 | started_on | date | no | started_on | ||||
| 6 | ends_on | date | yes | ends_on |
- primary key pk_subscription (id)
- foreign key fk_subscription_plan (plan_id) references plan (id) on delete restrict
- foreign key fk_subscription_tenant (tenant_id) references tenant (id) on delete cascade
- index ix_subscription_plan (plan_id)
- index ix_subscription_tenant (tenant_id)