Enhance server configuration for large file uploads and improve token handling. Increase request body size limit in the server to 20 GB, update registration token expiration logic to support infinite expiration, and adjust database schema to accommodate larger file sizes. Add detailed logging for file upload processes and error handling improvements.
This commit is contained in:
@@ -122,7 +122,7 @@ func (db *DB) migrate() error {
|
||||
file_type TEXT NOT NULL,
|
||||
file_path TEXT NOT NULL,
|
||||
file_name TEXT NOT NULL,
|
||||
file_size INTEGER NOT NULL,
|
||||
file_size BIGINT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
@@ -213,6 +213,17 @@ func (db *DB) migrate() error {
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS retry_count INTEGER DEFAULT 0`,
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS max_retries INTEGER DEFAULT 3`,
|
||||
`ALTER TABLE tasks ADD COLUMN IF NOT EXISTS timeout_seconds INTEGER`,
|
||||
// Migrate file_size from INTEGER to BIGINT to support large files (>2GB)
|
||||
// DuckDB doesn't support direct ALTER COLUMN TYPE, so we use a workaround:
|
||||
// 1. Add new column as BIGINT
|
||||
// 2. Copy data from old column
|
||||
// 3. Drop old column
|
||||
// 4. Rename new column
|
||||
// Note: This will only run if the column exists and is INTEGER
|
||||
`ALTER TABLE job_files ADD COLUMN IF NOT EXISTS file_size_new BIGINT`,
|
||||
`UPDATE job_files SET file_size_new = CAST(file_size AS BIGINT) WHERE file_size_new IS NULL`,
|
||||
`ALTER TABLE job_files DROP COLUMN IF EXISTS file_size`,
|
||||
`ALTER TABLE job_files RENAME COLUMN file_size_new TO file_size`,
|
||||
}
|
||||
|
||||
for _, migration := range migrations {
|
||||
@@ -220,6 +231,7 @@ func (db *DB) migrate() error {
|
||||
if _, err := db.Exec(migration); err != nil {
|
||||
// Log but don't fail - column might already exist or table might not exist yet
|
||||
// This is fine for migrations that run after schema creation
|
||||
// For the file_size migration, if it fails (e.g., already BIGINT), that's fine
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,16 +247,6 @@ func (db *DB) migrate() error {
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
for _, migration := range migrations {
|
||||
// DuckDB supports IF NOT EXISTS for ALTER TABLE, so we can safely execute
|
||||
if _, err := db.Exec(migration); err != nil {
|
||||
// Log but don't fail - column might already exist or table might not exist yet
|
||||
// This is fine for migrations that run after schema creation
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close closes the database connection
|
||||
|
||||
Reference in New Issue
Block a user