Skip to content

fix: 基础数据 sql 文件字段缺失报错#177

Merged
lu-yg merged 1 commit intoopentiny:developfrom
jizai1125:fix/sql-field-error
Feb 8, 2025
Merged

fix: 基础数据 sql 文件字段缺失报错#177
lu-yg merged 1 commit intoopentiny:developfrom
jizai1125:fix/sql-field-error

Conversation

@jizai1125
Copy link
Contributor

@jizai1125 jizai1125 commented Feb 7, 2025

Summary by CodeRabbit

  • New Features
    • Expanded the data initialization to include new entries that enhance UI blocks, components, and materials.
    • Introduced a redesigned page framework with structured layouts.
    • Improved historical tracking for content changes.
    • Added support for additional languages, including Simplified Chinese and American English.
    • Provided a developer account to streamline testing and early feedback.

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2025

Walkthrough

This pull request updates SQL initialization scripts for test environments. In the H2 script, multiple new INSERT statements add records to tables such as t_block, t_block_history, t_block_group, t_material, t_page, t_user, and t_i18n_lang. The MySQL script similarly adds new INSERT statements for UI components in the t_component table and updates entries in t_block and t_block_history. The changes expand the database schema with new data for blocks, components, users, and language support.

Changes

File(s) Change Summary
app/.../sql/h2/init_data_for_test.sql Added INSERT statements that create new records in t_block, t_block_history, t_block_group, t_material, t_page, t_user, and t_i18n_lang tables for test data initialization.
app/.../sql/mysql/init_data_for_test.sql Added and updated INSERT statements in the t_component, t_block_history, and t_block tables to introduce new UI component entries and refresh block definitions.

Poem

I'm a rabbit coding under moonlit skies,
Hopping through SQL with joyful surprise.
Blocks and components now take their place,
In data fields they softly embrace.
With every INSERT, our story takes flight—
A database garden blooming so bright!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/src/main/resources/sql/mysql/init_data_for_test.sql (1)

172-172: t_page JSON Content Review:
The INSERT into t_page includes a very detailed JSON structure representing page layout and component composition. While the record appears complete, the JSON content is quite complex; consider modularizing or commenting on key sections for better maintainability. This will enhance readability when future changes are needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c78c61 and ca29edc.

📒 Files selected for processing (2)
  • app/src/main/resources/sql/h2/init_data_for_test.sql (2 hunks)
  • app/src/main/resources/sql/mysql/init_data_for_test.sql (2 hunks)
🔇 Additional comments (30)
app/src/main/resources/sql/mysql/init_data_for_test.sql (16)

1-51: t_component Insertion Consistency Check:
The INSERT statements for the t_component table now list all the expected columns (e.g. id, version, name, name_en, icon, description, doc_url, screenshot, tags, keywords, dev_mode, npm, group, category, priority, snippets, schema_fragment, configure, public, framework, is_official, is_default, tiny_reserved, component_metadata, library_id, tenant_id, renter_id, site_id, created_by, created_time, last_updated_by, last_updated_time). This comprehensive column list should resolve the previous “字段缺失” (missing field) errors. The embedded JSON strings are detailed and appear to conform to the component schema. Please make sure that the JSON strings are valid in your target SQL engine and that data types (such as dates and numerical values) are consistent.


52-53: t_block_history Insertion Update:
The INSERT into t_block_history now provides complete content and metadata—including fields such as ref_id, message, version, label, framework, content (with its JSON structure), assets, and timestamps—which should eliminate missing field errors previously reported. It is advisable to verify that the JSON content for the block history (and any file paths or build info) is accurate and compatible with downstream processing.


54-55: t_block_group Entry Validation:
The new INSERT into t_block_group includes the fields id, name, app_id, platform_id, description, created_by, last_updated_by, created_time, last_updated_time, tenant_id, and site_id. This update ensures that all the required fields are provided, which should fix the earlier missing data issue.


56-56: t_material_history Record Update:
The INSERT statement for t_material_history now includes a full set of fields (e.g. id, ref_id, version, content, name, npm_name, framework, assets_url, image_url, description, material_size, tgz_url, unzip_tgz_root_path_url, unzip_tgz_files, created_by, last_updated_by, created_time, last_updated_time, tenant_id, site_id). The JSON content and asset references appear complete. Please double-check that the JSON for assets and scripts does not have any syntax issues that might cause runtime parsing errors.


58-58: t_tenant Record Completeness:
The INSERT into t_tenant now provides all necessary fields (id, name_cn, name_en, description, created_by, last_updated_by, created_time, last_updated_time). This should help avoid schema mismatches in multi-tenant setups.


60-60: r_material_history_block Mapping Verification:
The INSERT into r_material_history_block correctly establishes the relationship between material history and block history using the appropriate foreign keys. It is important to ensure that the referenced IDs (in this case, the material_history_id and block_history_id) exist in their parent tables to maintain referential integrity.


62-111: Bulk Insertion for r_material_history_component:
A series of INSERT statements now map a material history record to multiple components (from component_id 73 through 121). This batch insertion is comprehensive and should guarantee that each material history record is associated with the correct set of components. Since many rows are being inserted here, please verify that all component IDs referenced exist in the t_component table and that any foreign key constraints are met.


112-161: Mapping in r_material_component:
The INSERT statements for r_material_component (covering component IDs 73 through 121) ensure that the relationship between the material and its components is explicitly defined. This consistency across mapping tables should prevent missing field errors. A final check on the integrity of these IDs against the master component table is recommended.


164-164: r_material_block Insertion Verification:
The INSERT into r_material_block sets up the mapping between material history and block records. All expected fields are provided, and it looks aligned with the overall schema updates.


166-166: t_app Record Details:
The INSERT for t_app now includes an extensive list of fields—such as name, app_website, platform_id, platform_history_id, publish_url, editor_url, visit_url, image_url, assets_url, state, published, home_page_id, css, config, constants, data_handler, description, latest, git_group, project_name, branch, is_demo, is_default, template_type, set_template_time, set_template_by, set_default_by, framework, global_state, default_lang, extend_config, data_hash, can_associate, data_source_global, created_by, last_updated_by, created_time, last_updated_time, tenant_id, and site_id. This completeness should prevent prior omission errors. Please verify that all URL fields and JSON configurations (for example, the constants and global_state) are current and appropriate for your environment.


168-169: t_block Content and Build Info:
The INSERT statement for t_block now provides a very detailed JSON content block—including state, methods, children components, schema, dataSource, dependencies, and build information. This update includes additional fields (e.g. assets, last_build_info, tags, latest_version, latest_history_id, screenshot, path, occupier_by, is_official, public, is_default, tiny_reserved, npm_name, i18n, platform_id, app_id, content_blocks, created_by, last_updated_by, created_time, last_updated_time, tenant_id, site_id) that should entirely address any missing field issues. Due to the complexity of the JSON data, please validate that all nested structures are correctly escaped and conform to the expected design.


170-170: t_material Record Integrity:
The INSERT into t_material now includes fields for id, name, npm_name, framework, assets_url, image_url, published, latest_version, latest_history_id, public, last_build_info, description, is_official, is_default, tiny_reserved, component_library_id, material_category_id, material_size, tgz_url, unzip_tgz_root_path_url, unzip_tgz_files, created_by, last_updated_by, created_time, last_updated_time, tenant_id, and site_id. This update appears to resolve missing field issues and now carries full metadata for the material package.


174-174: t_user Entry Check:
The user record insertion now provides essential details (id, username, email, enable, created_by, last_updated_by, created_time, last_updated_time, tenant_id, site_id, is_admin, is_public) ensuring that the schema requirements are met. This update should prevent field omission errors in user management.


175-176: t_i18n_lang Enhancements:
Both INSERT statements for t_i18n_lang now supply the necessary fields (id, lang, label, created_by, last_updated_by, created_time, last_updated_time) to correctly seed the internationalization language data. This will support multi-language UI components and is implemented consistently.


177-177: t_platform Record Completeness:
The INSERT into t_platform is now comprehensive—providing fields such as name, published, last_build_info, description, latest_version, latest_history_id, material_history_id, image_url, sort_plugins, sort_toolbar, is_default, prettier_opts, set_default_by, app_extend_config, data_hash, business_category_id, theme_id, platform_url, vscode_url, tenant_id, site_id, created_by, last_updated_by, created_time, and last_updated_time. This should fully comply with the schema requirements and eliminate missing field errors. Verify that numeric, string, and JSON fields use the proper formats.


178-178: t_platform_history Record Verification:
The INSERT into t_platform_history now includes fields for id, ref_id, version, name, publish_url, description, vscode_url, material_history_id, sub_count, material_pkg_name, material_version, image_url, tenant_id, renter_id, site_id, created_by, last_updated_by, created_time, and last_updated_time. This detailed historical record should now work without field omission issues. Make sure that the publish URL and version data are current.

app/src/main/resources/sql/h2/init_data_for_test.sql (14)

1-30: t_component Insert Statements – Complete Field Coverage
All INSERTs into the t_component table now list all required columns (e.g. id, version, name, name_en, icon, description, doc_url, screenshot, tags, keywords, dev_mode, npm, "group", category, priority, snippets, schema_fragment, configure, last_updated_by, created_time, last_updated_time, public, framework, created_by, is_official, is_default, tiny_reserved, tenant_id, component_metadata, site_id). This should address the previous “字段缺失” errors. Please double‐check that every non‑nullable field receives an appropriate value (or default) and that the JSON values are correctly escaped.


31-31: t_block_history Insert – Field and JSON Validity
The INSERT into t_block_history now includes a complete list of fields, and the inserted JSON (in the content column) appears well structured. Ensure that the JSON content is valid and matches the expected schema of the application.


33-33: t_block_group Insert – Consistency Check
The t_block_group record provides all expected fields (id, name, app_id, platform_id, description, created_by, last_updated_by, created_time, last_updated_time, tenant_id, site_id). No fields seem to be missing; please confirm that these match with the updated schema definitions.


35-35: t_material_history Insert – Comprehensive Data
The t_material_history INSERT now includes all required columns. Verify that the JSON string provided for the assets (and any material versioning details) is valid. Also, check that the version and description fields now meet the non‑nullable constraints that might have caused errors previously.


37-37: t_tenant Insert – Basic Tenant Record
The tenant record is straightforward and appears to include all necessary columns. Just ensure that the tenant name and description conform to expected formats.


39-39: r_material_history_block Insert – Valid Association
The INSERT for r_material_history_block correctly maps a material_history record to a block_history record. Verify that the referenced ids (1, 1) match the records in the corresponding tables.


40-68: r_material_component Inserts – Foreign Key Consistency
The series of INSERT statements for r_material_component (lines 40–68) consistently supply id, material_id, and component_id values. It’s important to double‑check that each component_id used here exists in t_component and that the material_id is valid.


71-98: r_material_history_component Inserts – Correct Mapping
The r_material_history_component records (lines 71–98) appear to correctly relate material history with its component records. The sequential ids and corresponding component references seem consistent with expectations.


100-100: r_material_block Insert – Single Record Check
The INSERT into r_material_block on line 100 is a single record mapping material to block. Ensure that this relationship is valid as per the database design.


102-102: t_app Insert – Complex Application Configuration
The t_app INSERT (line 102) is quite complex with many JSON configuration fields (e.g. css, config, constants, data_handler, global_state). Although it appears complete, please verify that all newly required fields (introduced to resolve missing field errors) are mapped correctly and that the JSON values are valid. Consider wrapping this block in a transaction if not already done.


104-104: t_block Insert – Updated Block Definition
The INSERT into t_block (line 104) now provides a complete set of fields—including the previously missing ones—that define the block’s properties, content, dependencies, etc. Please review the large JSON content for any potential escaping issues and ensure its structure complies with the expected format.


106-106: t_material Insert – Full Field Inclusion
The t_material INSERT (line 106) now lists all required columns such as latest_version, latest_history_id, public, and last_build_info. Verify that the values (including the JSON for build info) are correct and that any defaults required by the schema are provided.


108-108: t_page Insert – Complete Page Data
The t_page INSERT (line 108) includes detailed page_content in JSON format along with other metadata like route, depth, and content_blocks. Please ensure that the structure meets the front‑end requirements and that all required fields are present.


110-112: t_user and t_i18n_lang Inserts – User and Language Setup
The t_user and t_i18n_lang inserts (lines 110–112) look complete. The new developer account and the language support records for Simplified Chinese and American English now include all required fields.

@lu-yg lu-yg merged commit f73178e into opentiny:develop Feb 8, 2025
1 check passed
lu-yg pushed a commit to lu-yg/tiny-engine-backend-java that referenced this pull request Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants