{"id":15350157,"url":"https://github.com/mars/diesel-pg-timestamp-usage","last_synced_at":"2025-04-15T03:32:04.605Z","repository":{"id":139297721,"uuid":"120215444","full_name":"mars/diesel-pg-timestamp-usage","owner":"mars","description":"🔬 Working sample of UTC timestamps with Rust/Diesel/Postgres","archived":false,"fork":false,"pushed_at":"2018-02-12T23:44:49.000Z","size":7,"stargazers_count":23,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T15:11:48.910Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.marsi.science/utc-timestamps-with-diesel/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mars.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-04T19:23:57.000Z","updated_at":"2024-03-27T07:15:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"77122825-0d8e-4ec4-84a0-8e5bb5d92bfb","html_url":"https://github.com/mars/diesel-pg-timestamp-usage","commit_stats":{"total_commits":3,"total_committers":2,"mean_commits":1.5,"dds":"0.33333333333333337","last_synced_commit":"87354e6b8e9dd2ed70a7ca803a586f103c6624c8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fdiesel-pg-timestamp-usage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fdiesel-pg-timestamp-usage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fdiesel-pg-timestamp-usage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Fdiesel-pg-timestamp-usage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mars","download_url":"https://codeload.github.com/mars/diesel-pg-timestamp-usage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249001571,"owners_count":21196402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T11:57:45.157Z","updated_at":"2025-04-15T03:32:04.340Z","avatar_url":"https://github.com/mars.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Timestamps with Diesel.rs \u0026 Postgres\n\nExample using UTC timestamps with the Rust language database ORM [Diesel](https://diesel.rs).\n\n🌱💚 *Please note, I am new to Rust. I could not find a clear example for this basic task, so here's what I figured out. No guarantees about correctness. Please [open an issue](https://github.com/mars/diesel-pg-timestamp-usage/issues) to give feedback. I'd love to find better ways to do this.* \n\n\n## Requirements\n\n* [Rust + Cargo](https://www.rust-lang.org)\n* [Postgres](https://www.postgresql.org/download/)\n* `cargo install diesel_cli --no-default-features --features postgres`\n\n\n## Usage\n\n```bash\nexport DATABASE_URL=postgres://postgres@localhost:5432/diesel-pg-timestamp-usage\ndiesel setup\n```\n\nNow, build \u0026 run the program:\n\n```\ncargo run\n```\n\n🏁 Each time it's run, a new example record will be inserted with the current timestamp. You should see output like:\n\n```\nInserted example: Example { id: 3, created_at: 2018-02-04T19:35:20.404570, updated_at: Some(2018-02-04T19:35:20.404570) }\n```\n\n\n## Architecture\n\nAs the [Diesel Getting Started guide](http://diesel.rs/guides/getting-started/) recommends:\n\n* [src/migrations/](src/migrations/)\n  * SQL commands to setup the database\n  * generated by `diesel migration generate $NAME`\n  * executed by `diesel migration run`\n* [src/schema.rs](src/schema.rs)\n  * the typed database schema\n  * generated by `diesel print-schema`\n* [src/models.rs](src/models.rs)\n  * structs that represent Diesel records in Rust\n  * created by hand\n\nAnd for this example,\n\n* [src/main.rs](src/main.rs)\n  * the high-level database connection \u0026 query program\n\n\n### Original setup\n\n```bash\nexport DATABASE_URL=postgres://postgres@localhost:5432/diesel-pg-timestamp-usage\ndiesel setup\ndiesel migration generate create-example\n# Write code in `migrations/up.sql` \u0026 `down.sql`\ndiesel migration run\ndiesel migration redo\ndiesel print-schema \u003e src/schema.rs\n# Write code in `src/models.rs`\n# Write code in `src/main.rs`\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmars%2Fdiesel-pg-timestamp-usage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmars%2Fdiesel-pg-timestamp-usage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmars%2Fdiesel-pg-timestamp-usage/lists"}