{"id":21230103,"url":"https://github.com/fgforrest/darwin","last_synced_at":"2025-07-10T16:32:43.919Z","repository":{"id":57738249,"uuid":"306593572","full_name":"FgForrest/Darwin","owner":"FgForrest","description":"Darwin is a small Java library that helps applications to setup and evolve their database schema over the time. Evolution is based on SQL patch application and aims at traceability, predictability and reliability. It has been for 13 years in production systems.","archived":false,"fork":false,"pushed_at":"2023-12-15T12:46:33.000Z","size":478,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-06T12:07:13.686Z","etag":null,"topics":["autoupdate","database","database-schema","evolution","java","model","sql"],"latest_commit_sha":null,"homepage":"http://edee.one","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FgForrest.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-10-23T09:46:41.000Z","updated_at":"2024-04-25T13:28:44.000Z","dependencies_parsed_at":"2023-12-19T03:03:25.812Z","dependency_job_id":null,"html_url":"https://github.com/FgForrest/Darwin","commit_stats":{"total_commits":42,"total_committers":3,"mean_commits":14.0,"dds":"0.30952380952380953","last_synced_commit":"7a4469949f712d6ab367a38776271051564a815b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FgForrest/Darwin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FgForrest%2FDarwin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FgForrest%2FDarwin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FgForrest%2FDarwin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FgForrest%2FDarwin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FgForrest","download_url":"https://codeload.github.com/FgForrest/Darwin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FgForrest%2FDarwin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264608149,"owners_count":23636685,"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":["autoupdate","database","database-schema","evolution","java","model","sql"],"created_at":"2024-11-20T23:35:19.035Z","updated_at":"2025-07-10T16:32:43.264Z","avatar_url":"https://github.com/FgForrest.png","language":"Java","readme":"# Darwin - helps to evolve your database schema\n\nDarwin is one of our oldest libraries, which we still use extensively - its origins date back to 2007. It allows easy \nevolution of the data model for your application. Darwin runs migration SQL scripts in a specific dialect according \nto clearly defined rules. It probably originated much earlier than the open-source variants of \n[Liquibase](https://www.liquibase.org/) or [FlywayDB](https://flywaydb.org/). It is also much simpler, but it represents \na reliable \"[Kalashnikov](https://en.wikipedia.org/wiki/AK-47)\" for us, which is universal and reliable in its \nsimplicity.\n\n***Disclaimer:** we took original source code that works for more than 13 years in production and updated it to JDK 8 version\nand up-to-date Java classes and Spring framework. Architecture, design and tests are mostly originates several years ago.*\n\nThe library allows you to maintain SQL scripts on classpath, allowing you to create the tables that your application \nneeds, not only for one specific database, but for different ones at once (ie in parallel you can maintain \nboth MySQL and Oracle schema for your universal libraries). Darwin decides which one to apply after starting \nthe application and finding out the database type from the [DataSource](https://docs.oracle.com/javase/7/docs/api/javax/sql/DataSource.html) \nobject.\n\nAs you further develop your application, you will soon find that the existing table structure does not suit you and \nneeds to be expanded or changed. To do this, all you have to do is to save the so-called patch files in the Darwin folder, \ncontaining in your name the version number of the application for which this structure is needed. The next time you \nstart the application, Darwin will compare the current version of your application (ie the one you just started) with \nthe version it last applied to the database schema. If the application version is newer, it finds all patches between \nthe two versions and applies them to the schema one by one.\n\nAt the same time, Darwin pays close attention to the \"transactionality\" of changes, and even if the database does not \nsupport transaction for schema changes (ie it cannot properly roll back DDL SQL statements), it remembers which SQL \nstatements it actually executed as part of the patch and which did not. Thanks to this, it can start its activity even \nin the middle of a half-applied patch. This is especially handy in the development phase.\n\nThe library allows for a modular approach, so it can be instantiated in the application, for example, 20 times \nfor different shared libraries.\n\nDarwin also pays great attention to the traceability of everything he has done with your database. All statements he \nexecuted at your instruction are logged in its tables with all necessary information such as the date the patch was \ndiscovered in the application, the date the patch was applied to the db, the duration of individual SQL statements, \nany exception that fell out of the database when much more.\n\nDarwin also includes a [Locker](src/main/java/one/edee/darwin/locker/Locker.java) tool that allows you to synchronize \ntasks within a cluster if a shared database exists. Darwin uses this [Locker](src/main/java/one/edee/darwin/locker/Locker.java) \nclass to apply SQL patches to only one of the nodes when running the same application on multiple \nnodes in a cluster at the same time, and the other instances of Darwin obediently wait for the migration to complete. \nHowever, you can use the tool for other purposes. For example, we use it relatively actively to control the execution \nof asynchronous tasks not only within the cluster, but also on one instance of the JVM.\n\nFor more information see section [How to use](#how-to-use)\n\n## Prerequisites\n\n- JDK 1.8+\n- Commons Logging (1.2.0+)\n- Spring framework (5.3.0+), works also on 4.3.X older version although not compilable due to JUnit tests\n\n## Supported databases\n\n- MySQL\n- Oracle\n- H2\n\nDo you missing one? Fill a pull request!\n\n## How to compile\n\nUse standard Maven 3 command:\n\n```\nmvn clean install\n```\n\n## How to run tests\n\nStart databases:\n\n```\ndocker-compose -f docker/docker-compose.yml up \n```\n\nRun your tests in IDE or run:\n\n```\nmvn clean test\n```\n\nHelp us maintain at least 80% code coverage!\n\n## How to use\n\nSee separate chapters for details:\n\n- [How to integrate to your project](src/main/resources/META-INF/darwin/docs/how-to-integrate-to-your-project.md)\n- [How to create migration scripts](src/main/resources/META-INF/darwin/docs/how-to-create-migration-scripts.md)\n- [How to switch to Darwin with existing database](src/main/resources/META-INF/darwin/docs/how-to-introduce-darwin-to-existing-db.md)\n- [How to make programmable scripts](src/main/resources/META-INF/darwin/docs/how-to-make-programmable-scripts.md)\n- [How to user locker for intra-cluster synchronization](src/main/resources/META-INF/darwin/docs/how-to-use-locker-synchronization.md)\n\n## Implementation notes:\n\n- [Versioning rules](src/main/resources/META-INF/darwin/docs/versioning.md)\n- [Patch content rules and escaping](src/main/resources/META-INF/darwin/docs/content-rules.md)\n- [Infrastructural tables](src/main/resources/META-INF/darwin/docs/infrastructural-tables.md)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgforrest%2Fdarwin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgforrest%2Fdarwin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgforrest%2Fdarwin/lists"}