-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: keinsell <[email protected]>
- Loading branch information
Showing
29 changed files
with
488 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
flake.lock linguist-generated=true | ||
src/lib/migration/sql/*.sql linguist-detectable linguist-language=sql | ||
src/lib/migration/sql/2_add_substance_data.sql binary linguist-vendored | ||
src/lib/migration/migrations/*.sql linguist-detectable linguist-language=sql | ||
src/lib/migration/sql/20250101000002_import_substance.sql binary linguist-vendored | ||
docs/*.md linguist-detectable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Project's Journal | ||
|
||
## 2025 | ||
|
||
### January | ||
|
||
#### 01 | ||
|
||
- **Spent 4 hours** working on implementing a migration toolkit with `Atlas`, only to realize that it’s not really | ||
compatible with code-first ORMs like `SeaORM` and adds more complexity than just writing migrations manually in Rust. | ||
Well, these things happen. For now, it’s fine for the current scope, but I’ll likely remove `Atlas` in the future. It | ||
seems better suited for cloud-native applications, whereas for our **local-first application**, tools like `Sqitch` | ||
and `Prisma` seem like more fitting options. **Atlas** does have its use cases, but it’s not a good fit here. | ||
|
||
- **Cleaned up the database schema**—we had a lot of unnecessary, chemical-specific data that wasn’t adding any real | ||
value to the project. Now, we’re only storing the essential information, which keeps the database clean and focused, | ||
without unnecessary bloat. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
DEFAULT_DATABASE_CONNECTION_URI := "sqlite:///tmp/neuronek.sqlite" | ||
schema_format := "{{ sql . }}" | ||
dev_db := "sqlite://dev?mode=memory" | ||
migration_dir := "./migrations" | ||
schema_file := "schema.sql" | ||
|
||
inspect connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
atlas schema inspect -u {{ connection_uri }} | ||
|
||
pull connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
atlas schema inspect -u "{{ connection_uri }}" --format '{{ schema_format }}' > {{ schema_file }} | ||
|
||
push connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
atlas schema apply \ | ||
-u "{{ connection_uri }}" \ | ||
--to file://schema.sql \ | ||
--dev-url "{{ dev_db }}" | ||
|
||
plan migration_name connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
@just hash | ||
atlas migrate diff {{ migration_name }} \ | ||
--dir "file://{{ migration_dir }}" \ | ||
--to "file://{{ schema_file }}" \ | ||
--dev-url "{{ dev_db }}" | ||
|
||
create migration_name: | ||
atlas migrate new {{ migration_name }} | ||
|
||
up connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
@just hash | ||
atlas migrate apply \ | ||
--url "{{ connection_uri }}" | ||
|
||
hash: | ||
atlas migrate hash --dir="file://{{ migration_dir }}" | ||
|
||
fresh: | ||
@just hash | ||
@just clean | ||
@just up | ||
@just pull | ||
|
||
clean connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
atlas schema clean -u "{{ connection_uri }}" --auto-approve | ||
|
||
baseline connection_uri=DEFAULT_DATABASE_CONNECTION_URI: | ||
atlas migrate diff baseline \ | ||
--dir "file://{{ migration_dir }}" \ | ||
--dev-url "{{ dev_db }}" \ | ||
--to "{{ connection_uri }}" \ | ||
|
||
generate: | ||
sea-orm-cli generate entity \ | ||
--compact-format \ | ||
--ignore-tables=seaql_migrations,atlas_schema_revisions \ | ||
--output-dir="./../orm" \ | ||
-u="{{ DEFAULT_DATABASE_CONNECTION_URI }}" \ | ||
--with-serde=both \ | ||
--with-copy-enums |
17 changes: 0 additions & 17 deletions
17
src/lib/migration/m20020101_000002_create_database_schema.rs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/lib/migration/migrations/20250101000001_add_ingestion_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- Create "ingestion" table | ||
CREATE TABLE `ingestion` | ||
( | ||
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
`substance_name` varchar NOT NULL, | ||
`route_of_administration` varchar NOT NULL, | ||
`dosage` float NOT NULL, | ||
`ingested_at` datetime_text NOT NULL, | ||
`updated_at` datetime_text NOT NULL, | ||
`created_at` datetime_text NOT NULL | ||
); | ||
-- Create "seaql_migrations" table | ||
CREATE TABLE IF NOT EXISTS `seaql_migrations` | ||
( | ||
`version` varchar NOT NULL, | ||
`applied_at` bigint NOT NULL, | ||
PRIMARY KEY (`version`) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.