go-crm initial

This commit is contained in:
2026-04-21 17:34:58 -03:00
parent 5b8107c169
commit f8135d0e1b
24 changed files with 641 additions and 125 deletions

View File

@@ -6,7 +6,7 @@ import (
"os"
"path/filepath"
_ "github.com/mattn/go-sqlite3"
_ "github.com/glebarez/sqlite"
)
const schema = `
@@ -59,16 +59,16 @@ CREATE TABLE IF NOT EXISTS services (
CREATE TABLE IF NOT EXISTS scheduling (
schedule_id INTEGER PRIMARY KEY AUTOINCREMENT,
customer_id INTEGER NOT NULL,
client_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
service_id INTEGER NOT NULL,
plan_date TEXT,
confirmed_date TEXT,
time TEXT,
status TEXT DEFAULT 'pending',
notes TEXT,
created_at INTEGER NOT NULL,
FOREIGN KEY (client_id) REFERENCES clients(client_id),
FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
FOREIGN KEY (client_id) REFERENCES clients(client_id)
FOREIGN KEY (service_id) REFERENCES services(service_id)
);
CREATE TABLE IF NOT EXISTS payments (
@@ -109,9 +109,11 @@ CREATE TABLE IF NOT EXISTS answers (
FOREIGN KEY (client_id) REFERENCES clients(client_id),
FOREIGN KEY (question_id) REFERENCES questions(question_id)
);
`
var dbPath = filepath.Join(os.Getenv("WORKDIR"), "data", "go-crm.db")
var dbPath = "data/go-crm.db"
func Init(path string) (*sql.DB, error) {
if path != "" {
@@ -123,7 +125,7 @@ func Init(path string) (*sql.DB, error) {
return nil, fmt.Errorf("failed to create data directory: %w", err)
}
database, err := sql.Open("sqlite3", dbPath)
database, err := sql.Open("sqlite", dbPath)
if err != nil {
return nil, fmt.Errorf("failed to open database: %w", err)
}