Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deployments and domains #50

Merged
merged 1 commit into from
Jan 9, 2024
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
20 changes: 19 additions & 1 deletion doseid/migrations/0002_projects.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,29 @@ CREATE TYPE deployment_status AS ENUM ('queued', 'building', 'error', 'canceled'

CREATE TABLE IF NOT EXISTS deployments (
id UUID NOT NULL,
value TEXT NOT NULL,
commit_id TEXT NOT NULL,
commit_metadata jsonb NOT NULL,
project_id UUID NOT NULL,
owner_id UUID NOT NULL,
status deployment_status NOT NULL,
build_logs jsonb NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id)
);

CREATE TYPE service_type AS ENUM ('project', 'storage');

CREATE TABLE IF NOT EXISTS domains (
id UUID NOT NULL,
name TEXT NOT NULL,
service_type service_type NOT NULL,
project_id UUID,
storage_id UUID,
deployment_id TEXT,
owner_id UUID NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
51 changes: 51 additions & 0 deletions doseid/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,54 @@ pub struct Project {
pub updated_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
}

#[derive(sqlx::Type, Serialize, Deserialize, Debug)]
#[sqlx(type_name = "status", rename_all = "lowercase")]
pub enum DeploymentStatus {
Queued,
Building,
Error,
Canceled,
Ready,
}

pub struct Deployment {
pub id: Uuid,
pub commit_id: String,
pub commit_metadata: Value,
pub project_id: Uuid,
pub owner_id: Uuid,
pub status: DeploymentStatus,
pub updated_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
}

#[derive(sqlx::Type, Serialize, Deserialize, Debug)]
#[sqlx(type_name = "service_type", rename_all = "lowercase")]
pub enum ServiceType {
Queued,
Building,
Error,
Canceled,
Ready,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Domain {
pub id: Uuid,
pub name: String,
pub service_type: ServiceType,
pub project_id: Option<Uuid>,
pub storage_id: Option<Uuid>,
pub deployment_id: Option<String>,
pub owner_id: Uuid,
pub updated_at: DateTime<Utc>,
pub created_at: DateTime<Utc>,
}

impl Domain {
pub fn new(mut domain: Domain) -> Domain {
domain.name = domain.name.to_lowercase();
domain
}
}