-
-
Notifications
You must be signed in to change notification settings - Fork 178
037 Auto create SQL updates for Componets in JCB
Hi. I would like to demonstrate to you one of the latest features that's been added to JCB. A feature request was made about 11 days ago. Auto generate update SQL? After a lengthy discussion the decision was made to add the feature and I am basically done doing. First let me give you some background so you can understand where we coming from. When you create a component in Joomla, then you have a set of views, and these views and the back end are linked to a set of tables. 00:00:38
On the installation of the component, for example, if we do so here with JCB, it builds the tables for those views on installation. So then if you go to the back end of the component, and you create a new item, it stores the value in the database, that it can be retrieved. That's very basic. The reality is 00:01:17 if you as a developer make a change to this component, which involves new tables. You would need to add extra script to your 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.
We going to demonstrate this. 00:01:47 In JCB there used to be a way to do that, which still works. A way for you to manually add the new SQL statements that are needed to make the update, it was done under version updates tab. You would click on version updates tab and you 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.
What I'm going to do now is, you'll see that at the moment, this admin view has only 1, 2, 3, 4, 5, 6, 00:02:38 views. I'm going to add another view to settings component. You can see it doesn't have these buttons ticked. I don't not know how to resolve this. It seems like it is a Joomla problem. Because there are multiple columns in this view. If you close it and click it again it fixes that anyway. I'm going to add a new view 00:03:09 called help documents and make some minor changes to the defaults. Add it to the 7th position, click save and click save again. We add a new view which means a new table to the database. We haven't written any of the SQL, because with the new changes this is going to be done for you automatically on the moment you compile this component. We are going again and compile this component. You will see it's version, it is still 1.4.1. 00:03:49 We compiling it.
Now what the system is doing, it is checking the history and it's making a lot of calculation to dynamically realize that there is been a new table increment the version number. If I now install this component, I go and open that component. I'll see that the new view is here, if I open the view there is no errors. 00:04:20 If I create new, it'll automatically start behaving the way that is expected. Let say, text 'hi' we are targeting the external sources. 00:04:43 You can see the database already stores the values, and the new table is therefore in the database and working as expected. You realize that this means that our JCB component has been updated. If I refresh this page, you'll see that the version number has been incremented. 00:05:14 And if you open the version updates and scroll down you would see 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. 00:05:44
This also works not only with the adding of a new view, but also if you were to add a field to an existing view. Let me demonstrate that quickly. I'm going to be adding a new field to the preacher view. I'm simply going to select any fields since I will removed it again. Let's call it image. I'm going to add in field - image, Allignment - left in tab, order in edit - 2. 00:06:27 Save. Save and close. Now I've added a new field to preachers, and again I'll be going to the compiler, I'll select the component and compile. Again since it detected there's been a field changed, it incremented the version number. If I install the component and we go to the component, to the preachers view, we'll now see 00:07:02 that new field is there, image. If I was to select an image, and save. Oops I see I actually missed it, the reason was that this component didn't have any history. I had to go and make a few changes.
Take it into account that if you are building a component from the ground up, it will have history. 00:07:33 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