Add repository management functionality with CRUD operations

- Implemented repoService for database interactions including count, list, get, create, update, and delete operations.
- Created RepoManager component for managing repositories with a user interface.
- Added forms for creating and editing repositories, including validation and error handling.
- Integrated API calls for fetching, creating, updating, and deleting repositories.
- Enhanced user experience with loading states and action feedback messages.
This commit is contained in:
2026-02-01 04:30:17 +00:00
parent f1ed790cab
commit 29cd473190
13 changed files with 855 additions and 116 deletions

View File

@@ -37,6 +37,7 @@ async function createLicensesTable() {
repo_provider VARCHAR(32) NOT NULL,
repo_name VARCHAR(255) NOT NULL,
repo_base_url VARCHAR(255),
repo_id INT UNSIGNED NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
last_version_check_at DATETIME NULL,
@@ -52,6 +53,21 @@ async function createLicensesTable() {
"last_used_version",
"last_used_version VARCHAR(64) NULL AFTER last_version_check_at"
);
await ensureColumn(
"licenses",
"repo_id",
"repo_id INT UNSIGNED NULL AFTER repo_base_url"
);
await db
.query(
`ALTER TABLE licenses
ADD CONSTRAINT fk_licenses_repo_id
FOREIGN KEY (repo_id) REFERENCES repos(id)
ON DELETE SET NULL`
)
.catch(() => {});
}
async function createLicenseHostnamesTable() {
@@ -70,8 +86,24 @@ async function createLicenseHostnamesTable() {
`);
}
async function createReposTable() {
await db.query(`
CREATE TABLE IF NOT EXISTS repos (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
provider VARCHAR(32) NOT NULL DEFAULT 'github',
owner_repo VARCHAR(255) NOT NULL,
base_url VARCHAR(255),
label VARCHAR(255),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY unique_repo_provider (provider, owner_repo)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
}
export async function ensureSchema() {
await createUsersTable();
await createReposTable();
await createLicensesTable();
await createLicenseHostnamesTable();
}