Drupal 7 Features Module Deployment

By shane
Mon, 2012-09-10 14:29
1 comments
Daily Dose of Drupal Episode #4

Share with Others

In this episode we again look at the Features module. We focus on how the Features module can be used for deployments across Drupal websites. Today you will learn:

  • How to use the Drupal Diff module to view Drupal Features changes
  • How to update a Drupal Feature Module using Drush
  • How to use a Drupal Features Module to deploy changing between a development and live Drupal website.
  • How to revert a Drupal Features Module using Drush

Code Karate's 5 Secrets to Becoming a Drupal 7 Ninja ebook contains a complete Introduction to the Drupal Features Module.

Hello there Daily Dose of Drupal faithful! Today we have another episode of the Daily Dose of Drupal brought to you by codekarate.com. Today is episode 4 and we are again going to look at the Features module but this time we are going to do a couple of things. First we’re going to see how the Drupal Diff module can fit in to the mix and we’re also going to talk about how this might work if you have a Drupal development and a Drupal live site.

So as you can see right where we left off last time with the Views module or excuse me, the Drupal Features module we created, working and we’re going to create or excuse me; change the view again and in this case we are going to go ahead and just pick one here; we’ll do a … we’ll go ahead and do a Line Chart this time.

So we’re going to apply that, save it and then we’re going to take a look. As you can see we now have a Line Chart which is different than the Test 1 site. Again; it is still just the regular old Pie Chart that we created the first time. In this case let’s imagine that the Test 2 site is our Drupal Development site and we’re going to be pushing out our Features module onto the test site which is over here and that will be our Drupal Live site.

So we’re going to first take a look at our Feature and see that on our Test 2 Development site it is overwritten. So we’re going to download the Drupal Diff module. So I’m using Drush to download the Diff module onto the Test 2 site, I’m also going to enable the Diff module using Drush.

So all I did was download the Drupal Diff module and enable it. Now if I refresh this page you can still see the Drupal feature is still overwritten, I can go into that and there’s actually the ability to review the overrides. So it actually compares the differences between what is the default which is the Drupal Features Module Code and what is in the database.

So you can see it’s now going to be a Line Chart because that’s what we set it as and we could do two things at this point; we could go ahead and recreate the Drupal Features module the way we discussed the last time which would recreate. this is going to then download the .tar file which we could then drop in over top of the existing code and get it to update but as you can see that seems a little complicated.

All we want to do here is we want to update the code that’s already here to represent what we have in our database and Drush allows us to do that very easily. So we’re going to go ahead and do Drush Features update and the shorten version is drush fu monthly_earning and we will run that and say the module already exist, do you really want to continue because this is actually going to update the code.

So now the code is updated we can go back here and refresh and you can see it’s now at the default status. So now that we have the updated module on the Drupal Development site; what we’re going to do is we’re going to actually drop this into the test.codekarate.com site which is going to act as our Drupal Production site or Live site in this example.

So I’m going to hop over to the Test 2 module’s directory and I’m going to just copy this monthly_earning module, I’m going to paste it over in the module’s directory on the test.codekarate.com site.

So after that we drop that in I am going to go into the module’s page and I could enable it from here … the Monthly Earning, I can also enable it from the Features page just to show this as an example and we’ll go ahead and save that and this is on our … what we consider to be our Live site for this example and it’s taking a little bit of time here but it should be … reloading here pretty shortly.

And even though we have the Drupal Content Type and the Drupal View on this site, it’ll still be okay, it’s going to just install the Features module that we created and it will then be able to revert this back to what is in the Drupal Features code. So you can see it’s overwritten, it’s saying that the view is overwritten because we made a change in the module on the Test 2 site which is the Development site.

What we’re going to do is we’re going to go ahead and revert this. Anytime you make a deployment from a Drupal Development site to a Drupal Live site you generally going to have to revert your Drupal Features module so we’ll revert this and we are going to go to that Monthly Earnings Report view and we will see there’s now a Line Graph with our 2 data points on it. One thing … as I mentioned before you always going to need to revert your Features module when it gets to the Live environment and you can also do this through Drush so if there was a change you can go ahead and do drush fr for Drush Features Revert, whatever your Features module name is, in this case monthly_marning. So it's drush fr monthly_earning

You’re also going to want to keep in mind that the reason you do this … the reason you have the Features module to deploy between different environments is so that you don’t actually have to touch the View or the Content Type in your Drupal Live environment because you’re just relying on the Features module to do the work. If you need to make a change we would come in to the Development site, make the change and the reason we’re just changing the type of graph is because it’s an easy change to show how it works but you can make changes to the content type or anything else that you exported with the Feature.

We go into the Feature module, we can confirm that it’s overwritten, we go ahead and do a Features update, this is just to show how deploying it multiple times worked, we are going to copy this over and in most cases; keep in mind that you’re going to be using not just a copy and paste like I am right here. You’re going to be using most likely a version control system like Git, BZR, SVN or some other type of version control system to actually move this between different environments.

So now that we’re updated we’re going to go to our Features module on the Live site and you’ll see it’s overwritten. So I’m going to go ahead and go into the test.codekarate.com site and show you that you can do a drush fr monthly_earning and this is going to show you that it’s going to revert the view, after you revert it go back, refresh, you’ll see that it should have been reverted … something apparently didn’t get reverted right, try that one more time once; interesting; well it’s not saying that it actually reverted it but let’s go ahead and check, I’m just trying to revert it this way just to see if this will work.

Okay so apparently there’s an issue so we’re going to do some troubleshooting so I’m going to go ahead in Drush download the Drupal Diff module and enable it again to see what is causing this to not work correctly. Well as soon as I went to actually see the difference it seems to have corrected itself.

One of the things you’ll notice is every once in a while with the Drupal Features module sometimes your Content Types or views will get into a rebuilding status, I don’t know if that’s exactly what we saw here but sometimes it takes a few seconds to let it refresh. So I’m guessing that was the case, I reverted it but it did not actually show as a reverted status.

You can see now it’s the Bar Graph as it should be. If I go back in to the Features module it’ll show that it’s in the default status. So that’s it for today, we’re not going to worry about that little issue, I think it seems to resolved itself and next time we will cover something besides the features module. So tune in tomorrow and we will go over something different. Thanks for watching the Daily Dose of Drupal, until next time.

Comments

I'm downloading a module as a feature which uses the taxonomies that are added using taxonomy manager. I have added the "FMR Categories" using the taxonomy manager. I am getting the "FMR Catagories" structure in taxonomy, but I am not getting the actual data for "FMR Catagories" on the server when I install the downloaded feature. Can You tell me what I should do?

Post new comment