dbdoc_engine 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.
- checksums.yaml +7 -0
- data/README.md +331 -0
- data/Rakefile +8 -0
- data/app/assets/builds/dbdoc_engine/application.css +5 -0
- data/app/assets/images/dbdoc_engine/arrowdown.svg +3 -0
- data/app/assets/images/dbdoc_engine/arrowhorizontal.svg +3 -0
- data/app/assets/images/dbdoc_engine/arrowleft.svg +3 -0
- data/app/assets/images/dbdoc_engine/changelog.svg +3 -0
- data/app/assets/images/dbdoc_engine/column_stats_dbdocs.svg +23 -0
- data/app/assets/images/dbdoc_engine/diagram.svg +3 -0
- data/app/assets/images/dbdoc_engine/double_arrow.svg +4 -0
- data/app/assets/images/dbdoc_engine/group_bu.svg +3 -0
- data/app/assets/images/dbdoc_engine/japan_circle.png +0 -0
- data/app/assets/images/dbdoc_engine/log_in_image.png +0 -0
- data/app/assets/images/dbdoc_engine/logo.svg +12 -0
- data/app/assets/images/dbdoc_engine/orange_changelog.svg +3 -0
- data/app/assets/images/dbdoc_engine/orange_fields.svg +23 -0
- data/app/assets/images/dbdoc_engine/orange_logo.svg +12 -0
- data/app/assets/images/dbdoc_engine/orange_table.svg +21 -0
- data/app/assets/images/dbdoc_engine/orange_updates.svg +43 -0
- data/app/assets/images/dbdoc_engine/orange_wiki.svg +3 -0
- data/app/assets/images/dbdoc_engine/search.svg +3 -0
- data/app/assets/images/dbdoc_engine/setting.svg +3 -0
- data/app/assets/images/dbdoc_engine/table_dbdocs.svg +21 -0
- data/app/assets/images/dbdoc_engine/uk_circle_transparent.png +0 -0
- data/app/assets/images/dbdoc_engine/update_stats_dbdocs.svg +43 -0
- data/app/assets/images/dbdoc_engine/wiki.svg +3 -0
- data/app/assets/stylesheets/dbdoc_engine/admin.css +176 -0
- data/app/assets/stylesheets/dbdoc_engine/admin_header.css +179 -0
- data/app/assets/stylesheets/dbdoc_engine/application.scss +1 -0
- data/app/assets/stylesheets/dbdoc_engine/changelog.css +173 -0
- data/app/assets/stylesheets/dbdoc_engine/dashboard.css +513 -0
- data/app/assets/stylesheets/dbdoc_engine/dbdoc_application.css +117 -0
- data/app/assets/stylesheets/dbdoc_engine/ecommerce.css +253 -0
- data/app/assets/stylesheets/dbdoc_engine/group_details.css +178 -0
- data/app/assets/stylesheets/dbdoc_engine/header.css +212 -0
- data/app/assets/stylesheets/dbdoc_engine/loading_spinner.css +127 -0
- data/app/assets/stylesheets/dbdoc_engine/login.css +213 -0
- data/app/assets/stylesheets/dbdoc_engine/schema_diagram.css +149 -0
- data/app/assets/stylesheets/dbdoc_engine/sidebar.css +296 -0
- data/app/assets/stylesheets/dbdoc_engine/table_details.css +417 -0
- data/app/controllers/dbdoc_engine/admin/base_controller.rb +23 -0
- data/app/controllers/dbdoc_engine/admin/dashboard_controller.rb +16 -0
- data/app/controllers/dbdoc_engine/admin/data_transfer_controller.rb +63 -0
- data/app/controllers/dbdoc_engine/admin/db_design_dynamic_tables_controller.rb +198 -0
- data/app/controllers/dbdoc_engine/admin/db_design_table_groups_controller.rb +107 -0
- data/app/controllers/dbdoc_engine/application_controller.rb +65 -0
- data/app/controllers/dbdoc_engine/concerns/internationalization.rb +57 -0
- data/app/controllers/dbdoc_engine/db_doc_sessions_controller.rb +33 -0
- data/app/controllers/dbdoc_engine/home_controller.rb +79 -0
- data/app/controllers/dbdoc_engine/schema_diagram_controller.rb +293 -0
- data/app/helper/dbdoc_engine/application_helper.rb +35 -0
- data/app/helpers/dbdoc_engine/application_helper.rb +4 -0
- data/app/helpers/dbdoc_engine/changelogs_helper.rb +27 -0
- data/app/helpers/dbdoc_engine/column_helper.rb +30 -0
- data/app/helpers/dbdoc_engine/db_design_dynamic_tables_helper.rb +15 -0
- data/app/helpers/dbdoc_engine/home_helper.rb +75 -0
- data/app/javascript/dbdoc_engine/application.js +12 -0
- data/app/javascript/dbdoc_engine/controllers/application.js +29 -0
- data/app/javascript/dbdoc_engine/controllers/auto_submit_controller.js +17 -0
- data/app/javascript/dbdoc_engine/controllers/chart_controller.js +58 -0
- data/app/javascript/dbdoc_engine/controllers/column-type_controller.js +149 -0
- data/app/javascript/dbdoc_engine/controllers/column_controller.js +362 -0
- data/app/javascript/dbdoc_engine/controllers/column_search_controller.js +42 -0
- data/app/javascript/dbdoc_engine/controllers/dbdoc_accordion_controller.js +42 -0
- data/app/javascript/dbdoc_engine/controllers/ecommerce_controller.js +73 -0
- data/app/javascript/dbdoc_engine/controllers/group_details_controller.js +88 -0
- data/app/javascript/dbdoc_engine/controllers/import_export_controller.js +200 -0
- data/app/javascript/dbdoc_engine/controllers/index.js +9 -0
- data/app/javascript/dbdoc_engine/controllers/language_controller.js +100 -0
- data/app/javascript/dbdoc_engine/controllers/loading_spinner_controller.js +48 -0
- data/app/javascript/dbdoc_engine/controllers/login_controller.js +75 -0
- data/app/javascript/dbdoc_engine/controllers/notification_controller.js +15 -0
- data/app/javascript/dbdoc_engine/controllers/schema_diagram_controller.js +1129 -0
- data/app/javascript/dbdoc_engine/controllers/select2_controller.js +67 -0
- data/app/javascript/dbdoc_engine/controllers/sidebar_controller.js +943 -0
- data/app/javascript/dbdoc_engine/controllers/table_details_controller.js +245 -0
- data/app/javascript/dbdoc_engine/controllers/table_group_validation_controller.js +148 -0
- data/app/javascript/dbdoc_engine/controllers/table_validation_controller.js +423 -0
- data/app/jobs/dbdoc_engine/application_job.rb +4 -0
- data/app/mailers/dbdoc_engine/application_mailer.rb +6 -0
- data/app/models/dbdoc_engine/application_record.rb +6 -0
- data/app/models/dbdoc_engine/concerns/soft_deletable.rb +30 -0
- data/app/models/dbdoc_engine/db_design_changelog.rb +44 -0
- data/app/models/dbdoc_engine/db_design_dynamic_column.rb +211 -0
- data/app/models/dbdoc_engine/db_design_dynamic_table.rb +124 -0
- data/app/models/dbdoc_engine/db_design_table_group.rb +88 -0
- data/app/models/dbdoc_engine/user.rb +21 -0
- data/app/queries/dbdoc_engine/admin_dashboard_queries.rb +71 -0
- data/app/queries/dbdoc_engine/db_design_changelog_queries.rb +68 -0
- data/app/queries/dbdoc_engine/db_design_dynamic_column_queries.rb +37 -0
- data/app/queries/dbdoc_engine/db_design_dynamic_table_commands.rb +106 -0
- data/app/queries/dbdoc_engine/db_design_dynamic_table_queries.rb +194 -0
- data/app/queries/dbdoc_engine/db_design_table_group_queries.rb +154 -0
- data/app/services/dbdoc_engine/db_design_dynamic_table_export_service.rb +38 -0
- data/app/services/dbdoc_engine/db_design_dynamic_table_handler_service.rb +49 -0
- data/app/services/dbdoc_engine/db_design_dynamic_tables_service.rb +21 -0
- data/app/services/dbdoc_engine/error_handler_service.rb +43 -0
- data/app/services/dbdoc_engine/schema_rb_import_service.rb +194 -0
- data/app/services/dbdoc_engine/schema_rb_parser_service.rb +339 -0
- data/app/services/dbdoc_engine/table_filter_service.rb +35 -0
- data/app/services/dbdoc_engine/table_groups_service.rb +199 -0
- data/app/services/dbdoc_engine/table_management_service.rb +192 -0
- data/app/views/dbdoc_engine/admin/dashboard/_action_badge.html.erb +11 -0
- data/app/views/dbdoc_engine/admin/dashboard/_changelog_rows.html.erb +22 -0
- data/app/views/dbdoc_engine/admin/dashboard/_changelog_table_headers.html.erb +8 -0
- data/app/views/dbdoc_engine/admin/dashboard/_filter_fields.html.erb +43 -0
- data/app/views/dbdoc_engine/admin/dashboard/index.html.erb +159 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_column_fields.html.erb +225 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_deleted_table_index.html.erb +110 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_foreign_key_fields.html.erb +51 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_form.html.erb +75 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_recent_activity.html.erb +39 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_table_columns.html.erb +127 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_table_index.html.erb +109 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/_table_information.html.erb +99 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/deleted_tables.html.erb +95 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/edit.html.erb +23 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/export_all_to_excel.xlsx.axlsx +240 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/export_to_excel.xlsx.axlsx +135 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/index.html.erb +109 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/new.html.erb +25 -0
- data/app/views/dbdoc_engine/admin/db_design_dynamic_tables/show_table_info.html.erb +125 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/_deleted_table_groups_list.html.erb +75 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/_form.html.erb +88 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/_table_groups_list.html.erb +82 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/deleted_groups.html.erb +60 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/edit.html.erb +25 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/index.html.erb +85 -0
- data/app/views/dbdoc_engine/admin/db_design_table_groups/new.html.erb +26 -0
- data/app/views/dbdoc_engine/db_doc_sessions/new.html.erb +59 -0
- data/app/views/dbdoc_engine/home/changelog_details.html.erb +80 -0
- data/app/views/dbdoc_engine/home/changelogs.html.erb +20 -0
- data/app/views/dbdoc_engine/home/group_details.html.erb +94 -0
- data/app/views/dbdoc_engine/home/index.html.erb +11 -0
- data/app/views/dbdoc_engine/home/partials/_action_badge.html.erb +11 -0
- data/app/views/dbdoc_engine/home/partials/_breadcrumb_navigation.html.erb +30 -0
- data/app/views/dbdoc_engine/home/partials/_changelog_rows.html.erb +35 -0
- data/app/views/dbdoc_engine/home/partials/_changelog_table_headers.html.erb +16 -0
- data/app/views/dbdoc_engine/home/partials/_column_headers.html.erb +23 -0
- data/app/views/dbdoc_engine/home/partials/_column_row.html.erb +157 -0
- data/app/views/dbdoc_engine/home/partials/_filter_form.html.erb +47 -0
- data/app/views/dbdoc_engine/home/partials/_group_section.html.erb +84 -0
- data/app/views/dbdoc_engine/home/partials/_pagination.html.erb +5 -0
- data/app/views/dbdoc_engine/home/partials/_stats_container.html.erb +46 -0
- data/app/views/dbdoc_engine/home/partials/_table_groups.html.erb +7 -0
- data/app/views/dbdoc_engine/home/partials/_table_information_section.html.erb +50 -0
- data/app/views/dbdoc_engine/home/partials/_table_section.html.erb +48 -0
- data/app/views/dbdoc_engine/home/table_details.html.erb +9 -0
- data/app/views/dbdoc_engine/schema_diagram/index.html.erb +102 -0
- data/app/views/dbdoc_engine/shared/_admin_header.html.erb +78 -0
- data/app/views/dbdoc_engine/shared/_header.html.erb +94 -0
- data/app/views/dbdoc_engine/shared/_js_translations.html.erb +3 -0
- data/app/views/dbdoc_engine/shared/_language_button.html.erb +14 -0
- data/app/views/dbdoc_engine/shared/_sidebar.html.erb +128 -0
- data/app/views/kaminari/dbdoc_engine/_first_page.html.erb +3 -0
- data/app/views/kaminari/dbdoc_engine/_gap.html.erb +3 -0
- data/app/views/kaminari/dbdoc_engine/_last_page.html.erb +3 -0
- data/app/views/kaminari/dbdoc_engine/_next_page.html.erb +3 -0
- data/app/views/kaminari/dbdoc_engine/_page.html.erb +9 -0
- data/app/views/kaminari/dbdoc_engine/_paginator.html.erb +17 -0
- data/app/views/kaminari/dbdoc_engine/_prev_page.html.erb +3 -0
- data/app/views/layouts/dbdoc_engine/application.html.erb +107 -0
- data/app/views/layouts/dbdoc_engine/header.html.erb +108 -0
- data/config/importmap.rb +11 -0
- data/config/locales/en.yml +307 -0
- data/config/locales/ja.yml +306 -0
- data/config/routes.rb +73 -0
- data/db/migrate/rails7/20250227060610_create_db_design_table_groups.rb +15 -0
- data/db/migrate/rails7/20250227094626_create_db_design_dynamic_tables.rb +19 -0
- data/db/migrate/rails7/20250228022732_create_db_design_dynamic_columns.rb +34 -0
- data/db/migrate/rails7/20250401051453_create_db_design_changelogs.rb +26 -0
- data/db/migrate/rails7/20250411040822_create_users.rb +14 -0
- data/db/migrate/rails7/20250421080851_add_missing_indexes_to_dbdoc_tables.rb +23 -0
- data/db/migrate/rails8/20250227060610_create_db_design_table_groups.rb +15 -0
- data/db/migrate/rails8/20250227094626_create_db_design_dynamic_tables.rb +19 -0
- data/db/migrate/rails8/20250228022732_create_db_design_dynamic_columns.rb +34 -0
- data/db/migrate/rails8/20250401051453_create_db_design_changelogs.rb +26 -0
- data/db/migrate/rails8/20250411040822_create_users.rb +14 -0
- data/db/migrate/rails8/20250421080851_add_missing_indexes_to_dbdoc_tables.rb +23 -0
- data/db/seeds.rb +28 -0
- data/lib/dbdoc_engine/engine.rb +57 -0
- data/lib/dbdoc_engine/version.rb +3 -0
- data/lib/dbdoc_engine.rb +9 -0
- data/lib/generators/dbdoc_engine/install/install_generator.rb +245 -0
- data/lib/generators/dbdoc_engine/uninstall/uninstall_generator.rb +196 -0
- data/lib/tasks/dbdoc_engine_tasks.rake +44 -0
- data/public/dbdoc_engine_assets/images/camel_chess_head.png +0 -0
- data/public/dbdoc_engine_assets/images/dblogo.svg +4 -0
- data/public/dbdoc_engine_assets/images/japan_circle.png +0 -0
- data/public/dbdoc_engine_assets/images/king_chess_head.png +0 -0
- data/public/dbdoc_engine_assets/images/login-bg.svg +44 -0
- data/public/dbdoc_engine_assets/images/logo.png +0 -0
- data/public/dbdoc_engine_assets/images/logo.svg +12 -0
- data/public/dbdoc_engine_assets/images/queen_chess_head.png +0 -0
- data/public/dbdoc_engine_assets/images/soldier_chess_headd.png +0 -0
- data/public/dbdoc_engine_assets/images/uk_circle_transparent.png +0 -0
- metadata +415 -0
data/config/routes.rb
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
DbdocEngine::Engine.routes.draw do
|
|
2
|
+
# ------------------------
|
|
3
|
+
# Authentication Routes
|
|
4
|
+
# ------------------------
|
|
5
|
+
get "login", to: "db_doc_sessions#new" # Login form
|
|
6
|
+
post "login", to: "db_doc_sessions#create" # Perform login
|
|
7
|
+
delete "logout", to: "db_doc_sessions#destroy" # Perform logout
|
|
8
|
+
|
|
9
|
+
# ------------------------
|
|
10
|
+
# Admin Namespace
|
|
11
|
+
# ------------------------
|
|
12
|
+
namespace :admin do
|
|
13
|
+
get "dashboard", to: "dashboard#index"
|
|
14
|
+
root to: "db_design_dynamic_tables#index" # Admin dashboard
|
|
15
|
+
get "export_data", to: "data_transfer#export_data", defaults: { format: :json }
|
|
16
|
+
post "import_data", to: "data_transfer#import_data"
|
|
17
|
+
post "import_schema", to: "data_transfer#import_schema"
|
|
18
|
+
|
|
19
|
+
# Routes for dynamic tables
|
|
20
|
+
resources :db_design_dynamic_tables, except: [ :show ] do
|
|
21
|
+
collection do
|
|
22
|
+
get :render_column_fields # Render dynamic column fields
|
|
23
|
+
get :columns # List columns for all tables
|
|
24
|
+
get :check_column_dependency # Check column dependencies
|
|
25
|
+
get :deleted_tables # View soft-deleted tables
|
|
26
|
+
get :export_all_to_excel, defaults: { format: "xlsx" } # Export all tables to Excel
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
member do
|
|
30
|
+
get :columns # List columns for a specific table
|
|
31
|
+
get :show_table_info # Show table metadata
|
|
32
|
+
patch :restore # Restore a soft-deleted table
|
|
33
|
+
delete :permanent_destroy # Permanently delete a table
|
|
34
|
+
get :export_to_excel # Export a specific table to Excel
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Routes for table groups
|
|
39
|
+
resources :db_design_table_groups, except: [ :show ] do
|
|
40
|
+
collection do
|
|
41
|
+
get :deleted_groups # View soft-deleted groups
|
|
42
|
+
get :existing_names # Check for existing group names
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
member do
|
|
46
|
+
patch :restore # Restore a soft-deleted group
|
|
47
|
+
delete :permanent_destroy # Permanently delete a group
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# ------------------------
|
|
53
|
+
# Public Routes
|
|
54
|
+
# ------------------------
|
|
55
|
+
root "home#index" # Application landing page
|
|
56
|
+
|
|
57
|
+
get "group_details/:id", to: "home#group_details", as: "group_details" # Show group details
|
|
58
|
+
get "table_details/:id", to: "home#table_details", as: "table_details" # Show table details
|
|
59
|
+
|
|
60
|
+
get "changelogs", to: "home#changelogs", as: "changelogs" # List all changelogs
|
|
61
|
+
get "changelogs/:id", to: "home#changelog_details", as: "changelog_details" # Show specific changelog
|
|
62
|
+
|
|
63
|
+
get "schema_diagram", to: "schema_diagram#index", as: "schema_diagram"
|
|
64
|
+
get "schema_diagram/data", to: "schema_diagram#data", defaults: { format: :json }
|
|
65
|
+
# Make sure the route is accessible via AJAX/fetch
|
|
66
|
+
match "schema_diagram/data", to: "schema_diagram#data", via: [ :get, :post ], as: "schema_diagram_data_ajax"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# ------------------------
|
|
70
|
+
# Health Check Route
|
|
71
|
+
# ------------------------
|
|
72
|
+
get "up", to: "rails/health#show", as: :rails_health_check # Health check endpoint
|
|
73
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Migration to create the db_design_table_groups table
|
|
2
|
+
# This table will store groups for organizing database designs, including a group name and color identifier.
|
|
3
|
+
class CreateDbDesignTableGroups < ActiveRecord::Migration[7.0]
|
|
4
|
+
def change
|
|
5
|
+
create_table :db_design_table_groups do |t|
|
|
6
|
+
t.string :group_name, null: false, comment: "Group name for logical grouping of tables"
|
|
7
|
+
t.string :group_color, null: false, comment: "Color identifier for UI representation"
|
|
8
|
+
t.string :created_by, comment: "Username or ID of the creator"
|
|
9
|
+
t.string :updated_by, comment: "Username or ID of the user who last updated the record"
|
|
10
|
+
t.datetime :deleted_at, index: true, comment: "Timestamp for soft deletion"
|
|
11
|
+
|
|
12
|
+
t.timestamps # created_at and updated_at
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Migration to create the db_design_dynamic_tables table
|
|
2
|
+
# This table will store dynamic tables within the db_design_table_groups, including table name, description, and creator information.
|
|
3
|
+
class CreateDbDesignDynamicTables < ActiveRecord::Migration[7.0]
|
|
4
|
+
def change
|
|
5
|
+
create_table :db_design_dynamic_tables do |t|
|
|
6
|
+
t.string :table_name, null: false, comment: "Unique table name identifier"
|
|
7
|
+
t.string :physical_table_name, null: false, comment: "Japanese table name"
|
|
8
|
+
t.references :db_design_table_group, null: false, foreign_key: true, comment: "Foreign key to table group"
|
|
9
|
+
t.text :description, comment: "Optional description for the table"
|
|
10
|
+
t.string :created_by, null: false, comment: "Username or ID of the creator"
|
|
11
|
+
t.string :updated_by, comment: "Username or ID of the person who last updated the table"
|
|
12
|
+
t.datetime :deleted_at, index: true, comment: "Timestamp for soft deletion"
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
add_index :db_design_dynamic_tables, :table_name, unique: true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Migration to create the db_design_dynamic_columns table
|
|
2
|
+
# This table stores columns for dynamic tables in the db_design schema.
|
|
3
|
+
# It includes metadata about the columns, such as name, data type, constraints (primary key, foreign key, not null, etc.),
|
|
4
|
+
# and other properties (like description and creator information).
|
|
5
|
+
class CreateDbDesignDynamicColumns < ActiveRecord::Migration[7.0]
|
|
6
|
+
def change
|
|
7
|
+
create_table :db_design_dynamic_columns do |t|
|
|
8
|
+
t.references :db_design_dynamic_table, null: false, foreign_key: true, comment: "Reference to the parent dynamic table"
|
|
9
|
+
t.string :column_name, null: false, comment: "Logical or display name for the column"
|
|
10
|
+
t.string :physical_column_name, null: false, comment: "Actual physical name used in DB schema"
|
|
11
|
+
t.string :data_type, null: false, comment: "Data type of the column"
|
|
12
|
+
t.integer :length, comment: "Optional field length or size (if applicable)"
|
|
13
|
+
t.integer :decimal_precision, comment: "decimal precision for floating point numbers"
|
|
14
|
+
t.boolean :is_primary_key, default: false, comment: "Marks column as primary key"
|
|
15
|
+
t.boolean :is_foreign_key, default: false, comment: "Marks column as foreign key"
|
|
16
|
+
t.string :foreign_table_name, comment: "Referenced table name (if foreign key)"
|
|
17
|
+
t.string :foreign_column_name, comment: "Referenced column name (if foreign key)"
|
|
18
|
+
t.string :relationship_type, comment: "Type of relationship (one-to-one, one-to-many, many-to-many) for foreign keys"
|
|
19
|
+
t.boolean :is_candidate_key, default: false, comment: "Marks column as a candidate key"
|
|
20
|
+
t.boolean :is_unique_key, default: false, comment: "Marks column as a unique key"
|
|
21
|
+
t.boolean :is_indexed, default: false, comment: "Marks column for indexing"
|
|
22
|
+
t.boolean :not_null, default: false, comment: "NOT NULL constraint"
|
|
23
|
+
t.string :default_value, comment: "Default value for the column"
|
|
24
|
+
t.string :sample_value, comment: "Sample value for the column"
|
|
25
|
+
t.text :description, comment: "Optional description for the column"
|
|
26
|
+
t.string :created_by, null: false, comment: "Username or ID of the creator"
|
|
27
|
+
t.datetime :deleted_at, index: true, comment: "Timestamp for soft deletion"
|
|
28
|
+
|
|
29
|
+
t.timestamps
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
add_index :db_design_dynamic_columns, [ :db_design_dynamic_table_id, :column_name ], unique: true, name: "index_dynamic_columns_on_table_and_column"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Migration to create the db_design_changelogs table
|
|
2
|
+
# This table stores logs of changes made to database design objects (e.g., tables, columns, groups).
|
|
3
|
+
# It includes metadata about the change such as the timestamp, action type (create, update, delete),
|
|
4
|
+
# entity type (table_group, table, column), entity name, a description of the change, and who made the change.
|
|
5
|
+
# Previous and new values are stored for tracking updates and deletions.
|
|
6
|
+
class CreateDbDesignChangelogs < ActiveRecord::Migration[7.0]
|
|
7
|
+
def change
|
|
8
|
+
create_table :db_design_changelogs do |t|
|
|
9
|
+
t.datetime :change_timestamp, null: false, comment: 'Timestamp when the change was made'
|
|
10
|
+
t.string :action_type, null: false, comment: 'Type of action (create, update, delete)'
|
|
11
|
+
t.string :entity_type, null: false, comment: 'Type of entity affected (table_group, table, column)'
|
|
12
|
+
t.string :entity_name, null: false, comment: 'Descriptive name of the entity (e.g., table_name, column_name)'
|
|
13
|
+
t.text :description, null: false, comment: 'Detailed explanation of the change'
|
|
14
|
+
t.string :changed_by, null: false, comment: 'User responsible for the change'
|
|
15
|
+
t.json :previous_values, comment: 'Stores previous values for updates or deletions'
|
|
16
|
+
t.json :new_values, comment: 'Stores new values for create or update actions'
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Adding indices to improve query performance
|
|
22
|
+
add_index :db_design_changelogs, :change_timestamp
|
|
23
|
+
add_index :db_design_changelogs, :entity_type
|
|
24
|
+
add_index :db_design_changelogs, :entity_name
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :dbdoc_engine_users do |t|
|
|
4
|
+
t.string :username, null: false, comment: "Username for authentication"
|
|
5
|
+
t.string :password_digest, null: false, comment: "Hashed password (bcrypt)"
|
|
6
|
+
t.string :role, null: false, default: "user", comment: "Role: user, admin, superadmin"
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :dbdoc_engine_users, :username, unique: true, name: "index_dbdoc_engine_users_on_username"
|
|
12
|
+
add_index :dbdoc_engine_users, :role, name: "index_dbdoc_engine_users_on_role"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class AddMissingIndexesToDbdocTables < ActiveRecord::Migration[7.0]
|
|
2
|
+
def change
|
|
3
|
+
add_index :db_design_changelogs, :action_type,
|
|
4
|
+
name: "index_db_design_changelogs_on_action_type"
|
|
5
|
+
|
|
6
|
+
add_index :db_design_changelogs, [:action_type, :change_timestamp],
|
|
7
|
+
name: "index_db_design_changelogs_on_action_type_and_timestamp",
|
|
8
|
+
order: { change_timestamp: :desc }
|
|
9
|
+
|
|
10
|
+
add_index :db_design_changelogs, :changed_by,
|
|
11
|
+
name: "index_db_design_changelogs_on_changed_by"
|
|
12
|
+
|
|
13
|
+
add_index :db_design_dynamic_columns, [:foreign_table_name, :foreign_column_name],
|
|
14
|
+
name: "index_dynamic_columns_on_fk_table_and_column"
|
|
15
|
+
|
|
16
|
+
add_index :db_design_dynamic_columns, :is_foreign_key,
|
|
17
|
+
name: "index_db_design_dynamic_columns_on_is_foreign_key"
|
|
18
|
+
|
|
19
|
+
add_index :db_design_table_groups, :group_name,
|
|
20
|
+
unique: true,
|
|
21
|
+
name: "index_db_design_table_groups_on_group_name"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Migration to create the db_design_table_groups table
|
|
2
|
+
# This table will store groups for organizing database designs, including a group name and color identifier.
|
|
3
|
+
class CreateDbDesignTableGroups < ActiveRecord::Migration[8.0]
|
|
4
|
+
def change
|
|
5
|
+
create_table :db_design_table_groups do |t|
|
|
6
|
+
t.string :group_name, null: false, comment: "Group name for logical grouping of tables"
|
|
7
|
+
t.string :group_color, null: false, comment: "Color identifier for UI representation"
|
|
8
|
+
t.string :created_by, comment: "Username or ID of the creator"
|
|
9
|
+
t.string :updated_by, comment: "Username or ID of the user who last updated the record"
|
|
10
|
+
t.datetime :deleted_at, index: true, comment: "Timestamp for soft deletion"
|
|
11
|
+
|
|
12
|
+
t.timestamps # created_at and updated_at
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Migration to create the db_design_dynamic_tables table
|
|
2
|
+
# This table will store dynamic tables within the db_design_table_groups, including table name, description, and creator information.
|
|
3
|
+
class CreateDbDesignDynamicTables < ActiveRecord::Migration[8.0]
|
|
4
|
+
def change
|
|
5
|
+
create_table :db_design_dynamic_tables do |t|
|
|
6
|
+
t.string :table_name, null: false, comment: "Unique table name identifier"
|
|
7
|
+
t.string :physical_table_name, null: false, comment: "Japanese table name"
|
|
8
|
+
t.references :db_design_table_group, null: false, foreign_key: true, comment: "Foreign key to table group"
|
|
9
|
+
t.text :description, comment: "Optional description for the table"
|
|
10
|
+
t.string :created_by, null: false, comment: "Username or ID of the creator"
|
|
11
|
+
t.string :updated_by, comment: "Username or ID of the person who last updated the table"
|
|
12
|
+
t.datetime :deleted_at, index: true, comment: "Timestamp for soft deletion"
|
|
13
|
+
|
|
14
|
+
t.timestamps
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
add_index :db_design_dynamic_tables, :table_name, unique: true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Migration to create the db_design_dynamic_columns table
|
|
2
|
+
# This table stores columns for dynamic tables in the db_design schema.
|
|
3
|
+
# It includes metadata about the columns, such as name, data type, constraints (primary key, foreign key, not null, etc.),
|
|
4
|
+
# and other properties (like description and creator information).
|
|
5
|
+
class CreateDbDesignDynamicColumns < ActiveRecord::Migration[8.0]
|
|
6
|
+
def change
|
|
7
|
+
create_table :db_design_dynamic_columns do |t|
|
|
8
|
+
t.references :db_design_dynamic_table, null: false, foreign_key: true, comment: "Reference to the parent dynamic table"
|
|
9
|
+
t.string :column_name, null: false, comment: "Logical or display name for the column"
|
|
10
|
+
t.string :physical_column_name, null: false, comment: "Actual physical name used in DB schema"
|
|
11
|
+
t.string :data_type, null: false, comment: "Data type of the column"
|
|
12
|
+
t.integer :length, comment: "Optional field length or size (if applicable)"
|
|
13
|
+
t.integer :decimal_precision, comment: "decimal precision for floating point numbers"
|
|
14
|
+
t.boolean :is_primary_key, default: false, comment: "Marks column as primary key"
|
|
15
|
+
t.boolean :is_foreign_key, default: false, comment: "Marks column as foreign key"
|
|
16
|
+
t.string :foreign_table_name, comment: "Referenced table name (if foreign key)"
|
|
17
|
+
t.string :foreign_column_name, comment: "Referenced column name (if foreign key)"
|
|
18
|
+
t.string :relationship_type, comment: "Type of relationship (one-to-one, one-to-many, many-to-one, many-to-many) for foreign keys"
|
|
19
|
+
t.boolean :is_candidate_key, default: false, comment: "Marks column as a candidate key"
|
|
20
|
+
t.boolean :is_unique_key, default: false, comment: "Marks column as a unique key"
|
|
21
|
+
t.boolean :is_indexed, default: false, comment: "Marks column for indexing"
|
|
22
|
+
t.boolean :not_null, default: false, comment: "NOT NULL constraint"
|
|
23
|
+
t.string :default_value, comment: "Default value for the column"
|
|
24
|
+
t.string :sample_value, comment: "Sample value for the column"
|
|
25
|
+
t.text :description, comment: "Optional description for the column"
|
|
26
|
+
t.string :created_by, null: false, comment: "Username or ID of the creator"
|
|
27
|
+
t.datetime :deleted_at, index: true, comment: "Timestamp for soft deletion"
|
|
28
|
+
|
|
29
|
+
t.timestamps
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
add_index :db_design_dynamic_columns, [ :db_design_dynamic_table_id, :column_name ], unique: true, name: "index_dynamic_columns_on_table_and_column"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Migration to create the db_design_changelogs table
|
|
2
|
+
# This table stores logs of changes made to database design objects (e.g., tables, columns, groups).
|
|
3
|
+
# It includes metadata about the change such as the timestamp, action type (create, update, delete),
|
|
4
|
+
# entity type (table_group, table, column), entity name, a description of the change, and who made the change.
|
|
5
|
+
# Previous and new values are stored for tracking updates and deletions.
|
|
6
|
+
class CreateDbDesignChangelogs < ActiveRecord::Migration[8.0]
|
|
7
|
+
def change
|
|
8
|
+
create_table :db_design_changelogs do |t|
|
|
9
|
+
t.datetime :change_timestamp, null: false, comment: 'Timestamp when the change was made'
|
|
10
|
+
t.string :action_type, null: false, comment: 'Type of action (create, update, delete)'
|
|
11
|
+
t.string :entity_type, null: false, comment: 'Type of entity affected (table_group, table, column)'
|
|
12
|
+
t.string :entity_name, null: false, comment: 'Descriptive name of the entity (e.g., table_name, column_name)'
|
|
13
|
+
t.text :description, null: false, comment: 'Detailed explanation of the change'
|
|
14
|
+
t.string :changed_by, null: false, comment: 'User responsible for the change'
|
|
15
|
+
t.json :previous_values, comment: 'Stores previous values for updates or deletions'
|
|
16
|
+
t.json :new_values, comment: 'Stores new values for create or update actions'
|
|
17
|
+
|
|
18
|
+
t.timestamps
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Adding indices to improve query performance
|
|
22
|
+
add_index :db_design_changelogs, :change_timestamp
|
|
23
|
+
add_index :db_design_changelogs, :entity_type
|
|
24
|
+
add_index :db_design_changelogs, :entity_name
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration[8.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :dbdoc_engine_users do |t|
|
|
4
|
+
t.string :username, null: false, comment: "Username for authentication"
|
|
5
|
+
t.string :password_digest, null: false, comment: "Hashed password (bcrypt)"
|
|
6
|
+
t.string :role, null: false, default: "user", comment: "Role: user, admin, superadmin"
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :dbdoc_engine_users, :username, unique: true, name: "index_dbdoc_engine_users_on_username"
|
|
12
|
+
add_index :dbdoc_engine_users, :role, name: "index_dbdoc_engine_users_on_role"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class AddMissingIndexesToDbdocTables < ActiveRecord::Migration[8.0]
|
|
2
|
+
def change
|
|
3
|
+
add_index :db_design_changelogs, :action_type,
|
|
4
|
+
name: "index_db_design_changelogs_on_action_type"
|
|
5
|
+
|
|
6
|
+
add_index :db_design_changelogs, [:action_type, :change_timestamp],
|
|
7
|
+
name: "index_db_design_changelogs_on_action_type_and_timestamp",
|
|
8
|
+
order: { change_timestamp: :desc }
|
|
9
|
+
|
|
10
|
+
add_index :db_design_changelogs, :changed_by,
|
|
11
|
+
name: "index_db_design_changelogs_on_changed_by"
|
|
12
|
+
|
|
13
|
+
add_index :db_design_dynamic_columns, [:foreign_table_name, :foreign_column_name],
|
|
14
|
+
name: "index_dynamic_columns_on_fk_table_and_column"
|
|
15
|
+
|
|
16
|
+
add_index :db_design_dynamic_columns, :is_foreign_key,
|
|
17
|
+
name: "index_db_design_dynamic_columns_on_is_foreign_key"
|
|
18
|
+
|
|
19
|
+
add_index :db_design_table_groups, :group_name,
|
|
20
|
+
unique: true,
|
|
21
|
+
name: "index_db_design_table_groups_on_group_name"
|
|
22
|
+
end
|
|
23
|
+
end
|
data/db/seeds.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
if defined?(DbdocEngine::User)
|
|
2
|
+
user_class = DbdocEngine::User
|
|
3
|
+
else
|
|
4
|
+
puts "Error: DbdocEngine::User model not found. Seeds cannot be loaded."
|
|
5
|
+
return
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
puts "Clearing existing #{user_class.name} records..."
|
|
9
|
+
user_class.destroy_all
|
|
10
|
+
|
|
11
|
+
users = [
|
|
12
|
+
{ username: "user", role: "user", password: "password123" },
|
|
13
|
+
{ username: "admin", role: "admin", password: "password123" },
|
|
14
|
+
{ username: "superadmin", role: "superadmin", password: "password123" }
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
puts "Creating users..."
|
|
18
|
+
users.each do |user_data|
|
|
19
|
+
user = user_class.create!(
|
|
20
|
+
username: user_data[:username],
|
|
21
|
+
role: user_data[:role],
|
|
22
|
+
password: user_data[:password],
|
|
23
|
+
password_confirmation: user_data[:password]
|
|
24
|
+
)
|
|
25
|
+
puts " Created #{user.role}: #{user.username}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
puts "DbdocEngine seed completed. Created #{user_class.count} users."
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require "rails/engine"
|
|
2
|
+
require "kaminari"
|
|
3
|
+
require "kaminari-bootstrap"
|
|
4
|
+
require "turbo-rails"
|
|
5
|
+
require "stimulus-rails"
|
|
6
|
+
require "inline_svg"
|
|
7
|
+
require "caxlsx"
|
|
8
|
+
require "caxlsx_rails"
|
|
9
|
+
require "zip"
|
|
10
|
+
require "select2-rails"
|
|
11
|
+
|
|
12
|
+
module DbdocEngine
|
|
13
|
+
class Engine < ::Rails::Engine
|
|
14
|
+
isolate_namespace DbdocEngine
|
|
15
|
+
|
|
16
|
+
config.autoload_paths += %W[
|
|
17
|
+
#{root}/app/models/concerns
|
|
18
|
+
#{root}/app/controllers/concerns
|
|
19
|
+
#{root}/app/models/DbdocEngine/concerns
|
|
20
|
+
#{root}/app/controllers/DbdocEngine/concerns
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
config.app_middleware.use(
|
|
24
|
+
Rack::Static,
|
|
25
|
+
urls: [ "/dbdoc_engine_assets" ], # URL prefix
|
|
26
|
+
root: DbdocEngine::Engine.root.join("public") # Engine's public dir
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Single consolidated initializer
|
|
30
|
+
initializer "dbdoc_engine.config" do |app|
|
|
31
|
+
# Asset paths
|
|
32
|
+
app.config.assets.paths << root.join("app/assets/stylesheets")
|
|
33
|
+
app.config.assets.paths << root.join("app/assets/images")
|
|
34
|
+
app.config.assets.paths << root.join("app/javascript") # Added JavaScript directory
|
|
35
|
+
app.config.assets.paths << root.join("node_modules/bootstrap/dist/js")
|
|
36
|
+
app.config.assets.paths << root.join("node_modules/@popperjs/core/dist/umd")
|
|
37
|
+
|
|
38
|
+
# Precompile list
|
|
39
|
+
app.config.assets.precompile += %w[
|
|
40
|
+
dbdoc_engine/application.css
|
|
41
|
+
dbdoc_engine/application.js
|
|
42
|
+
dbdoc_engine/*.svg
|
|
43
|
+
dbdoc_engine/*.png
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
# Importmap configuration
|
|
47
|
+
Rails.application.importmap.draw do
|
|
48
|
+
eval File.read(DbdocEngine::Engine.root.join("config/importmap.rb"))
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
app.config.importmap.cache_sweepers += [ root.join("app/javascript").to_s ]
|
|
52
|
+
end
|
|
53
|
+
rake_tasks do
|
|
54
|
+
load 'tasks/dbdoc_engine_tasks.rake'
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|