-
-
Notifications
You must be signed in to change notification settings - Fork 178
037 Auto create SQL updates for Componets in JCB
I would like to demonstrate one of the latest features that has been added to JCB. A feature request had been made: "Auto generate update SQL?". After a lengthy discussion the decision was made to add the feature and now it is basically done. First, some background regarding it. When a component is created in Joomla, you have a set of views, and these views and the back end are linked to a set of tables.
On the installation of the component, for example, as is done with JCB, it builds the tables for those views on installation. So if you go to the back end of the component, and create a new item, it stores the value in the database, that it can be retrieved. 00:01:17 As a developer make a change to this component which involves new tables, extra script need to be added to the components package upon installation. If it finds that there is already an existing component, it will update the database accordingly to the new settings, the new tables or any fields added.
In JCB there used to be a way to do that, which still works. A way to manually add the new SQL statements that are needed to make the update, it was done under the Version Updates tab. You would click on Version Updates tab and would add your specific SQL query script, and upon installation if the existing version is below this update, it will grab this and install it into the database creating the new tables.
This Admin View has only 1, 2, 3, 4, 5, 6, views. I'm going to add another view to this component. These buttons is not ticked. It seems to be a Joomla problem because there are multiple columns in this view. If it is closed and clicked again it fixes that. I am going to add a new view called 'Help Documents' and make some minor changes to the defaults. 00:03:14 Add it to the 7th position, click save and click save again. A new view has been added which means a new table to the database. We have not written any of the SQL, because with the new changes this is going to be done automatically the moment this component is compiled. We are and This component is going to be compiled again. Its version is still 1.4.1. Then it gets compiled.
The system is checking the history and it is making a lot of calculation to dynamically realize that there has been a new table increment version number. If this component is installed now ,and if that component is opened that the new view can be seen. I'll see is here. If the view is opened it does not show any errors. 00:04:20 If new is created, it automatically start as expected. For instance, text: 'hi'. This targets the external sources. 00:04:43 It may be seen that the database already stores the values, and the new table is therefore in the database and working as expected. This means that the JCB component has been updated. If this page is refreshed , it may be seen that the version number has been incremented. 00:05:14 If the version updates is opened it can be seen when you scroll down, that 1.4.1 got this new creating of a help document table and a new version(1.4.2) got allocated. We do not know what is this (https//github.com/SermonDisributor) link and so we add this (https//domain.com/.zip) demo link here which you need to manually update still. That is by far a tremendous improvement.
This also works not only with the adding of a new view, but also if a field is added to an existing view. To demonstrate: If a new field gets added to the Preacher view and any fields is selected, since it is going to be removed again. For example: Call it 'Image'.(See video) 00:06:27 Save and close. Now a new field has been added to preachers, and then return to the compiler, select the component and compile. Since it detected there has been a field changed, it incremented the version number. If the component is installed, it may be seen in the component in the Preachers view, that there is a new field , 'image'.00:07:02 If an image is selected, and saved. Oops, I actually missed it, the reason was that this component did not have any history. A few changes is necessary.
Take it into account that if you are building a component from the ground up, it will have history. This is only going to be happening when you have install a component via the import function in the components, or maybe using the demo component. I would advise open all the views and save them at least once, so that there is history recorded for that view. That is one of the drawbacks, there is really no way for me to my negate that issue. Since the history of each of these different items, being at the admin view and the fields needs to be created the moment that you saved the item. It can't be done before then. 00:08:14 Taking that an account, I'll recompile it again and fix that. It should increment it to 1.4.3. I will install that again. Going back refreshing the preacher, we will see that image field is back. Select an image. Click save and now you'll see that it does store the data for this image. 00:08:49 If we refresh the component, we will see that it is again incremented the version. If I open the update area, you will see that it added this new alter of the preacher table, adding the image field. It also added the new 00:09:16 version to this list. That is a quick demonstration of this new automated feature. It is in its very beta phase. We still going to be working on it to make sure that it's completely stable.
Please take a go at it if you find any bugs, look for other open issues, which someone already reported, and start commenting on that what you think should be done. If you don't find any, then please open an issue and let us fix this issue. 00:09:55 I think this will be a tremendous improvement to JCB, making it again with the one of the best Joomla component developing tools out there today. Where it is even writing your update SQL for you, being busy working and improving your component without being concerned about that.
- Home
- Beta Testing
- Custom Code
- PHP Settings
- Demo Component
-
Tutorials
- Hello World JCB
- Intro JCB Guide
- JCB Installation Steps
- Planning Components
- Field Type Overview
- Basic Fields Creation
- Admin View Management
- Advanced Field Usage
- Admin Component Integration
- Component Setting Customization
- Scripting Components
- Component FTP Options
- Dynamic Get Method
- Site View DynamicGet
- Site View Templates
- Template Setup Guide
- Layout Configuration Steps
- Custom Admin Management
- Adding Site Views
- Custom Admin Integration
- MySQL Demo Tweaking
- Global JCB Settings
- Custom Time Field
- User Helper Integration
- Email Helper Usage
- Message Store Email
- List View Unescape
- Export Import Customization
- Overwrite Custom Fields
- List Field Filtering
- Automatic Code Import
- Manual Code Implementation
- Component Export Import
- Custom Admin Buttons
- Translation Management
- Site View Permissions
- Component SQL Updates
- Site Edit Configuration
- JCB Backup System
- Helper Structure Integration
- JCB v2.5 Upgrade
- Tab Setup Guide
- JCB v2.6 Release
- Extended HelloWorld
- Field Rule Validation
- Community Snippets Intro
- Snippet Forking Tutorial
- Pull Request Snippets
- Library Manager Area
- Excel-based Translation
- Dynamic Router Details
- Database Auto Updates
- Subform Quick Demo
- VDM Package Import
- Dynamic File Inclusion
- File Field Upload
- Drag-n-Drop Upload
- Quick HelloWorld JCB
- Non-database Fields
- Dashboard Customization
- Menu Prefix Toggle
- Community JCB Packages
- Collaborative JCB Workflow
- JCB Package Install
- JCB JAB18 Event
- Convenient New Fields
- Component Language Strings
- Library Functionality Anticipation
- Join Field Relations
- License Template Change
- Code Reusability
- Local Dev Environment
- Extended Field Types
- Joomla Custom Fields
- Custom Field Expansion
- Site View Listing
- Run Expansion Method
- Form Site View
- Field URL Update
- Additional Helper Methods
- Field Validation Rules
- New Placeholder Feature
- Component Config Params
- Per-field Default Values