Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/server/migrations-crm/0002_marvelous_agent_zero.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE `crm_audit_log` (
`id` text PRIMARY KEY NOT NULL,
`site_id` text NOT NULL,
`actor_user_id` text NOT NULL,
`actor_role` text NOT NULL,
`action` text NOT NULL,
`target_id` text,
`occurred_at` integer NOT NULL
);
--> statement-breakpoint
CREATE INDEX `idx_crm_audit_site_time` ON `crm_audit_log` (`site_id`,`occurred_at`);--> statement-breakpoint
CREATE INDEX `idx_crm_audit_site_target` ON `crm_audit_log` (`site_id`,`target_id`);--> statement-breakpoint
CREATE INDEX `idx_crm_audit_occurred` ON `crm_audit_log` (`occurred_at`);
379 changes: 379 additions & 0 deletions apps/server/migrations-crm/meta/0002_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,379 @@
{
"version": "6",
"dialect": "sqlite",
"id": "d5ac3527-c40c-4c64-9a7c-33ee2819ab19",
"prevId": "6dbe8789-6aab-43b0-adb2-f05317a871c8",
"tables": {
"companies": {
"name": "companies",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"site_id": {
"name": "site_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"domain": {
"name": "domain",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'lead'"
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"owner_user_id": {
"name": "owner_user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"idx_companies_site_created": {
"name": "idx_companies_site_created",
"columns": [
"site_id",
"created_at"
],
"isUnique": false
},
"idx_companies_site_status": {
"name": "idx_companies_site_status",
"columns": [
"site_id",
"status"
],
"isUnique": false
},
"idx_companies_site_name": {
"name": "idx_companies_site_name",
"columns": [
"site_id",
"name"
],
"isUnique": true
},
"idx_companies_site_domain": {
"name": "idx_companies_site_domain",
"columns": [
"site_id",
"domain"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"contacts": {
"name": "contacts",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"site_id": {
"name": "site_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"external_user_id": {
"name": "external_user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"phone": {
"name": "phone",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"company": {
"name": "company",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"company_id": {
"name": "company_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "'lead'"
},
"source": {
"name": "source",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"notes": {
"name": "notes",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"owner_user_id": {
"name": "owner_user_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"idx_contacts_site_created": {
"name": "idx_contacts_site_created",
"columns": [
"site_id",
"created_at"
],
"isUnique": false
},
"idx_contacts_site_status": {
"name": "idx_contacts_site_status",
"columns": [
"site_id",
"status"
],
"isUnique": false
},
"idx_contacts_site_company": {
"name": "idx_contacts_site_company",
"columns": [
"site_id",
"company_id"
],
"isUnique": false
},
"idx_contacts_site_email": {
"name": "idx_contacts_site_email",
"columns": [
"site_id",
"email"
],
"isUnique": true
},
"idx_contacts_site_extuser": {
"name": "idx_contacts_site_extuser",
"columns": [
"site_id",
"external_user_id"
],
"isUnique": true
}
},
"foreignKeys": {
"contacts_company_id_companies_id_fk": {
"name": "contacts_company_id_companies_id_fk",
"tableFrom": "contacts",
"tableTo": "companies",
"columnsFrom": [
"company_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"crm_audit_log": {
"name": "crm_audit_log",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"site_id": {
"name": "site_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"actor_user_id": {
"name": "actor_user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"actor_role": {
"name": "actor_role",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"action": {
"name": "action",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"target_id": {
"name": "target_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"occurred_at": {
"name": "occurred_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"idx_crm_audit_site_time": {
"name": "idx_crm_audit_site_time",
"columns": [
"site_id",
"occurred_at"
],
"isUnique": false
},
"idx_crm_audit_site_target": {
"name": "idx_crm_audit_site_target",
"columns": [
"site_id",
"target_id"
],
"isUnique": false
},
"idx_crm_audit_occurred": {
"name": "idx_crm_audit_occurred",
"columns": [
"occurred_at"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
Loading
Loading