Skip to content

Commit 4d1ee00

Browse files
authored
Merge pull request #2 from dancixx/feat/migrate-to-sqlite
feat: migrate to sqlite
2 parents 6ee08d5 + 2e63671 commit 4d1ee00

File tree

27 files changed

+390
-302
lines changed

27 files changed

+390
-302
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-sql-gui-ui"
3-
version = "1.0.0-alpha.3"
3+
version = "1.0.0-alpha.4"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -20,5 +20,6 @@ thaw = "0.1.3"
2020
common = { path = "common" }
2121

2222

23+
2324
[workspace]
2425
members = ["src-tauri", "common"]

common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "common"
3-
version = "1.0.0-alpha.3"
3+
version = "1.0.0-alpha.4"
44
edition = "2021"
55

66
[dependencies]

common/src/drivers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod postgresql;

common/src/drivers/postgresql.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
pub struct Postgresql {
5+
pub user: String,
6+
pub password: String,
7+
pub host: String,
8+
pub port: String,
9+
}
10+
11+
impl Postgresql {
12+
pub fn new(user: String, password: String, host: String, port: String) -> Self {
13+
Self {
14+
user,
15+
password,
16+
host,
17+
port,
18+
}
19+
}
20+
}

common/src/enums.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::fmt::Display;
2+
3+
use serde::{Deserialize, Serialize};
4+
5+
use super::projects::postgresql::Postgresql;
6+
7+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
8+
pub enum Project {
9+
POSTGRESQL(Postgresql),
10+
}
11+
12+
#[derive(Clone, Serialize, Deserialize)]
13+
pub enum Drivers {
14+
POSTGRESQL,
15+
}
16+
17+
impl Display for Drivers {
18+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19+
match self {
20+
Drivers::POSTGRESQL => write!(f, "POSTGRESQL"),
21+
}
22+
}
23+
}
24+
25+
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
26+
pub enum ProjectConnectionStatus {
27+
Connected,
28+
#[default]
29+
Disconnected,
30+
}

common/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
pub mod project;
1+
pub mod drivers;
2+
pub mod enums;
3+
pub mod projects;
4+
pub mod utils;

common/src/project.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

common/src/projects/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod postgresql;

common/src/projects/postgresql.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::collections::BTreeMap;
3+
4+
use crate::{drivers::postgresql::Postgresql as PostgresqlDriver, enums::ProjectConnectionStatus};
5+
6+
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
7+
pub struct Postgresql {
8+
pub name: String,
9+
pub driver: PostgresqlDriver,
10+
pub schemas: Option<Vec<String>>,
11+
pub tables: Option<BTreeMap<String, Vec<(String, String)>>>,
12+
pub connection_status: ProjectConnectionStatus,
13+
}
14+
15+
impl Default for Postgresql {
16+
fn default() -> Self {
17+
Self {
18+
name: String::default(),
19+
driver: PostgresqlDriver::default(),
20+
schemas: None,
21+
tables: None,
22+
connection_status: ProjectConnectionStatus::Disconnected,
23+
}
24+
}
25+
}

common/src/utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use crate::enums::Project;
2+
3+
pub fn project_matcher(project: Project) -> (String, Project) {
4+
match project {
5+
Project::POSTGRESQL(project) => (project.name.clone(), Project::POSTGRESQL(project)),
6+
}
7+
}

0 commit comments

Comments
 (0)