databasium 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +32 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +109 -0
  5. data/Rakefile +6 -0
  6. data/app/assets/builds/application.js +9045 -0
  7. data/app/assets/builds/application.js.map +7 -0
  8. data/app/assets/builds/databasium.css +2 -0
  9. data/app/assets/config/databasium_manifest.js +1 -0
  10. data/app/assets/javascript/databasium/application.js +2 -0
  11. data/app/assets/javascript/databasium/controllers/attribute_controller.js +27 -0
  12. data/app/assets/javascript/databasium/controllers/collapse_controller.js +18 -0
  13. data/app/assets/javascript/databasium/controllers/error_controller.js +15 -0
  14. data/app/assets/javascript/databasium/controllers/filter_controller.js +224 -0
  15. data/app/assets/javascript/databasium/controllers/flash_controller.js +18 -0
  16. data/app/assets/javascript/databasium/controllers/graph_controller.js +193 -0
  17. data/app/assets/javascript/databasium/controllers/index.js +7 -0
  18. data/app/assets/javascript/databasium/controllers/layout_controller.js +13 -0
  19. data/app/assets/javascript/databasium/controllers/model_controller.js +32 -0
  20. data/app/assets/javascript/databasium/controllers/new_migration_controller.js +107 -0
  21. data/app/assets/javascript/databasium/controllers/relation_controller.js +10 -0
  22. data/app/assets/javascript/databasium/controllers/search_controller.js +23 -0
  23. data/app/assets/javascript/databasium/controllers/table_controller.js +283 -0
  24. data/app/assets/javascript/databasium/controllers/table_select_controller.js +19 -0
  25. data/app/assets/javascript/databasium/controllers/toggle_controller.js +28 -0
  26. data/app/assets/javascript/databasium/controllers/validation_controller.js +78 -0
  27. data/app/assets/javascript/databasium/shapes/erd_table_shape.js +54 -0
  28. data/app/assets/stylesheets/databasium/application.css +15 -0
  29. data/app/assets/stylesheets/databasium/colors.css +55 -0
  30. data/app/assets/stylesheets/databasium/custom.css +36 -0
  31. data/app/assets/stylesheets/databasium/databasium_engine.css +6 -0
  32. data/app/assets/stylesheets/databasium/pagy-tailwind.css +66 -0
  33. data/app/components/base.rb +50 -0
  34. data/app/components/databasium/collapsable.rb +62 -0
  35. data/app/components/databasium/forms/model.rb +147 -0
  36. data/app/components/databasium/forms/search.rb +31 -0
  37. data/app/components/databasium/global/error.rb +60 -0
  38. data/app/components/databasium/global/flash.rb +73 -0
  39. data/app/components/databasium/global/header_actions.rb +36 -0
  40. data/app/components/databasium/global/sidebar.rb +45 -0
  41. data/app/components/databasium/global/suggestion.rb +25 -0
  42. data/app/components/databasium/migrations/action.rb +39 -0
  43. data/app/components/databasium/migrations/file.rb +58 -0
  44. data/app/components/databasium/migrations/form.rb +222 -0
  45. data/app/components/databasium/migrations/header_actions.rb +87 -0
  46. data/app/components/databasium/migrations/migration_status.rb +22 -0
  47. data/app/components/databasium/migrations/preview.rb +29 -0
  48. data/app/components/databasium/migrations/show_turbo_stream.rb +19 -0
  49. data/app/components/databasium/migrations/sidebar.rb +28 -0
  50. data/app/components/databasium/models/attributes.rb +49 -0
  51. data/app/components/databasium/models/form.rb +100 -0
  52. data/app/components/databasium/models/header_actions.rb +51 -0
  53. data/app/components/databasium/models/model_preview.rb +31 -0
  54. data/app/components/databasium/models/sidebar.rb +25 -0
  55. data/app/components/databasium/models/templates/attribute.rb +99 -0
  56. data/app/components/databasium/models/templates/base.rb +6 -0
  57. data/app/components/databasium/models/templates/relation.rb +56 -0
  58. data/app/components/databasium/models/templates/validation.rb +285 -0
  59. data/app/components/databasium/navigation/base_icon.rb +32 -0
  60. data/app/components/databasium/navigation/frontend_icon.rb +17 -0
  61. data/app/components/databasium/navigation/get_icon.rb +26 -0
  62. data/app/components/databasium/navigation/icon.rb +28 -0
  63. data/app/components/databasium/navigation/icon_panel.rb +26 -0
  64. data/app/components/databasium/navigation/post_icon.rb +25 -0
  65. data/app/components/databasium/navigation/put_icon.rb +18 -0
  66. data/app/components/databasium/records/filter.rb +73 -0
  67. data/app/components/databasium/records/foreign_records.rb +84 -0
  68. data/app/components/databasium/records/header_actions.rb +110 -0
  69. data/app/components/databasium/records/show_turbo_stream.rb +75 -0
  70. data/app/components/databasium/records/sidebar.rb +23 -0
  71. data/app/components/databasium/records/table/record_panel.rb +60 -0
  72. data/app/components/databasium/records/table/row.rb +104 -0
  73. data/app/components/databasium/records/table.rb +125 -0
  74. data/app/components/databasium/records/table_turbo_frame.rb +37 -0
  75. data/app/components/databasium/records/utilities.rb +25 -0
  76. data/app/components/databasium/schemas/header_actions.rb +99 -0
  77. data/app/components/databasium/schemas/sidebar.rb +25 -0
  78. data/app/components/databasium/search_results/migrations.rb +37 -0
  79. data/app/components/databasium/search_results/models.rb +36 -0
  80. data/app/components/databasium/search_results/schema_models.rb +37 -0
  81. data/app/components/databasium/search_results/tables.rb +31 -0
  82. data/app/components/databasium/type_select.rb +35 -0
  83. data/app/controllers/databasium/application_controller.rb +68 -0
  84. data/app/controllers/databasium/homepage_controller.rb +5 -0
  85. data/app/controllers/databasium/migrations_controller.rb +186 -0
  86. data/app/controllers/databasium/models_controller.rb +105 -0
  87. data/app/controllers/databasium/records_controller.rb +156 -0
  88. data/app/controllers/databasium/schemas_controller.rb +52 -0
  89. data/app/helpers/databasium/application_helper.rb +4 -0
  90. data/app/helpers/databasium/heroicon_helper.rb +21 -0
  91. data/app/helpers/databasium/models_helper.rb +4 -0
  92. data/app/jobs/databasium/application_job.rb +4 -0
  93. data/app/mailers/databasium/application_mailer.rb +6 -0
  94. data/app/models/databasium/application_record.rb +5 -0
  95. data/app/models/model.json +0 -0
  96. data/app/services/databasium/migration.rb +176 -0
  97. data/app/services/databasium/model.rb +182 -0
  98. data/app/services/databasium/record.rb +65 -0
  99. data/app/services/databasium/schema.rb +146 -0
  100. data/app/views/base.rb +13 -0
  101. data/app/views/databasium/errors/non_development.rb +21 -0
  102. data/app/views/databasium/homepage/index.rb +29 -0
  103. data/app/views/databasium/migrations/index.rb +33 -0
  104. data/app/views/databasium/migrations/new.rb +29 -0
  105. data/app/views/databasium/models/index.rb +31 -0
  106. data/app/views/databasium/models/new.rb +37 -0
  107. data/app/views/databasium/records/index.rb +24 -0
  108. data/app/views/databasium/schemas/index.rb +39 -0
  109. data/app/views/layouts/databasium/application.rb +56 -0
  110. data/config/importmap.rb +12 -0
  111. data/config/initializers/heroicon.rb +12 -0
  112. data/config/initializers/pagy.rb +48 -0
  113. data/config/initializers/phlex.rb +19 -0
  114. data/config/routes.rb +31 -0
  115. data/config/tailwind.config.js +10 -0
  116. data/lib/databasium/engine.rb +57 -0
  117. data/lib/databasium/engine_mount.rb +37 -0
  118. data/lib/databasium/middleware/conditional_check_pending.rb +27 -0
  119. data/lib/databasium/templates/create_table_migration.rb.tt +29 -0
  120. data/lib/databasium/templates/migration.rb.tt +48 -0
  121. data/lib/databasium/templates/model.rb.tt +23 -0
  122. data/lib/databasium/version.rb +3 -0
  123. data/lib/databasium.rb +11 -0
  124. data/lib/tasks/databasium_tasks.rake +4 -0
  125. metadata +272 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c8b3337e940bd7f5fbd9b5c7017fd0c5f54fba5c39bca36632ee289749c229db
4
+ data.tar.gz: c7476f1123cd0f7617a64a36f46542a9260a12938b421add487d3bbf5340c3bc
5
+ SHA512:
6
+ metadata.gz: cdb17cf6669a8b896fb43d1671ab96feac30e653f212f3756a9f0e4165e574f2eb87febfde90a20ebc8047dc7c6511d1ba27281adf4d28f353fb9cb3d9fe3d15
7
+ data.tar.gz: d1a1ac46eb65b486570e841c02fc33734ff28a3c023e9eb54eba02d418c4e754343b7888ab765278953c99c2222347ab4d7f17e8f70c1548f87f272c4a86e4f8
data/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.1.0] - 2026-05-16
8
+
9
+ First public release. Databasium is a development-only Rails engine for managing and exploring Rails databases from the browser.
10
+
11
+ ### Added
12
+
13
+ - **Records** — browse tables, view rows, create and update records, bulk delete
14
+ - **Migrations** — create migration files from the UI, run pending migrations, roll back individual migrations
15
+ - **Models** — generate Active Record model files with attributes, associations, and validations
16
+ - **Schema** — interactive entity-relationship diagram (ERD) synced from Active Record models
17
+ - Rails engine mounted at `/databasium` with Phlex views, Hotwire (Turbo), and Stimulus controllers
18
+ - Precompiled Tailwind CSS and importmap integration for engine assets
19
+ - Homepage with links to each section
20
+
21
+ ### Security
22
+
23
+ - Boot-time abort when the gem is loaded in production, to prevent accidental use outside development
24
+ - Controller-level guard when routes are mounted outside development (renders a warning page)
25
+
26
+ ### Requirements
27
+
28
+ - Ruby 3.2+
29
+ - Rails 8.0.2+
30
+ - Host app must use Active Record
31
+
32
+ [0.1.0]: https://github.com/Unitato1/databasium/releases/tag/v0.1.0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Robert Svihla
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # Databasium
2
+
3
+ Databasium is a Rails engine that gives you a browser UI for working with your database during local development. Browse and edit records, write and run migrations, generate Active Record models, and visualize your schema as an entity-relationship diagram (ERD).
4
+
5
+ **Development only.** Databasium writes files under `db/migrate` and `app/models` and is not safe to expose publicly. Do not EVER use it in production. Databasium tries to guard this on its own so it might crash you app if you forget about it. Is should be easy to test locally, just run:
6
+
7
+ ```bash
8
+ RAILS_ENV=production bin/rails s
9
+ ```
10
+
11
+ ## Requirements
12
+
13
+ - Ruby 3.2+
14
+ - Rails 8.0.2+
15
+ - A Rails app with **Active Record** models
16
+ - importmap-rails, turbo-rails, and stimulus-rails (installed automatically with the gem)
17
+ - Databasium ships precompiled CSS and registers its own importmap pins.
18
+
19
+ ## Installation
20
+
21
+ IMPORTANT: Add the gem to your **development** group only:
22
+
23
+ ```ruby
24
+ # Gemfile
25
+ group :development do
26
+ gem "databasium"
27
+ end
28
+ ```
29
+
30
+ Then install and mount the engine:
31
+
32
+ ```bash
33
+ bundle install
34
+ ```
35
+
36
+ ```ruby
37
+ # config/routes.rb
38
+ Rails.application.routes.draw do
39
+ mount Databasium::Engine, at: "/databasium" if Rails.env.development?
40
+
41
+ # ...
42
+ end
43
+ ```
44
+
45
+ Visit [http://localhost:3000/databasium](http://localhost:3000/databasium) while running `bin/rails server` in development.
46
+
47
+ The mount path is detected automatically from your routes. To override (optional):
48
+
49
+ ```ruby
50
+ config.databasium.mount_path = "/admin/database"
51
+ ```
52
+
53
+ Pending-migration blocking is skipped only under the Databasium mount so you can run migrations from the UI; the rest of your app still shows the normal Rails pending-migration page.
54
+
55
+ ### Production safety
56
+
57
+ When `databasium` is in `group :development`, Bundler does not load it in production, so your app boots normally in production.
58
+
59
+ If the gem is loaded in production (for example, added outside the development group), Databasium aborts on boot to prevent accidental use.
60
+
61
+ ## Features
62
+
63
+ | Area | Description |
64
+ | -------------- | --------------------------------------------------------- |
65
+ | **Records** | CRUD interface for table data |
66
+ | **Migrations** | Create migration files, run pending migrations, roll back |
67
+ | **Models** | Generate Active Record model files from the UI |
68
+ | **Schema** | ERD view synced from your models |
69
+
70
+ Routes are mounted under `/databasium` (for example `/databasium/records`, `/databasium/migrations`)...
71
+
72
+ ## Developing the gem
73
+
74
+ Clone the repository and install dependencies:
75
+
76
+ ```bash
77
+ git clone https://github.com/Unitato1/databasium.git
78
+ cd databasium
79
+ bundle install
80
+ ```
81
+
82
+ The engine is developed against the dummy app in `test/dummy`. Prepare its database:
83
+
84
+ ```bash
85
+ ./test/dummy/bin/rails db:migrate
86
+ ./test/dummy/bin/rails db:seed
87
+ ```
88
+
89
+ Start the server from the gem root (this also watches and rebuilds Tailwind CSS):
90
+
91
+ ```bash
92
+ bin/rails server
93
+ ```
94
+
95
+ Open [http://127.0.0.1:3000/databasium](http://127.0.0.1:3000/databasium).
96
+
97
+ ## Status
98
+
99
+ Version **0.1.0** is an early release. Automated test coverage is limited; treat the API and UI as subject to change.
100
+
101
+ ## Contributing
102
+
103
+ I will be happy for any bug reports and pull requests.
104
+
105
+ I am open for updating and working on any changes in the future if there would be interest.
106
+
107
+ ## License
108
+
109
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ require "bundler/gem_tasks"