DrupalCon Prague 2013

Cómo planificar bien una migración técnica

Janis Janovskis, Florian Loretan  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

okay well hello everyone I think there's still some people coming in but we'll get started so today we're going to be talking about migrations and this is the one thing that we like to do before we start presentation on any topic is to ask well

why why would you want to migrate and in the case of migration the opposite question why wouldn't you migrate is actually a very good question because you have a website it works it's functional why would you want to migrate and well sometimes you

don't need to migrate you don't always need to migrate some sometimes you can just leave your website as it is or sometimes well as you mentioned yesterday you can also just shut it down and that's the end of it but sometimes you need to migrate

and yannis found this this quote and from a general I think you wanted to stop hmm a Russian politician who wanted to stop a bird migration and no you cannot do that it's impossible and in the same way when you need to migrate you know that you have to

migrate and so if you're stuck and with a system this could be an enterprise preparatory content management system it could be an old platform that's unmaintained when you need to migrate well you just have to migrate its natural thing and well when

you can't migrate or when you really have soon well it kind of feels like being in prison most famous prison is of course Alcatraz which gave its name to source a title of our session on our escape from alcatraz we have two fellow criminals here to to

assist you on this way this way out so hello everyone my name is Florian lorton I'm a software architect at winter crops Germany and I'm yiannis i'm a developer in when the crowd latvian office so he's welcome to our criminal session and now

let's get started not with the way it is now but with things well what are the different ways that people have done migrations before and actually we took it in a way let's let's we took it in a way really we look back to the history how people

actually migrated away or to some things and we look but really really far away in the history and then actually look back you know back in the day is about 4,000 years ago people had some writing so they basically writing things not in a computer soro and

pay for the writing things and stones so you had to do a pretty heavy stuff so you had to rely on quite reliable animals and firstly we use donkeys mules Sun camels to my great things from one place to another PP used to migrate data right we moved on and

we we became clever so we invented typing machine it's a great way to migrate the next thing when we became more clever they actually started to use more clever options things like copying and pasting has anyone done this no one its okay its okay its okay

bye yeah you're great people we're studying copying and pasting a friend of mine copied a book of 2,400 pages from webpage to an Excel spreadsheet so just for your inspiration if you can't get things done go back to old days right if we move to

the next stage we probably have braised so big in our organization so we don't have time to do this copying pasting so what we do we hire somebody well actually we don't hire anyone we just say somebody that we are going to hire that person and at

the end we just said I'm sorry we don't have budget you will be unpaid so and we'll give you this wonderful option to be in an Internet and a massive big organization we don't do that with some do we go mother to direct mortar direction we

want to talk about later land obviously we start to move things into various sophisticated systems things like drupal and then when we moved to drupal when there were no day when back in the days we didn't have any migration support kind of maintained

and software we used to do a custom script yeah if you can read it if you can read it thoroughly you'll get a chocolate for me right this is my own creation my own script the it went very well by the way there about fifteen hundred items files and some

some texts it went well but it had no backwards compatibility by that I mean it had no rollback options so you created nose and they were kind of stable stubborn and finally this is the thing I mostly like I've done many i've done this many times before

actually started the things in a more clever well this is in to insert into statements has anyone done this one two three two statement don't be afraid nothing weird yeah don't be afraid you can be honest here yeah we used to do insert answers by the

way if you can create by this you can create users you can take users from some weird database or a system of tables and just put them into a drupal database system for instance this is Drupal 7 good since we've covered the history we will now see how

to do things in a proper way in a triple way let's go and head and look at the way how we can do it yeah so in the modern Drupal ecosystem there are two main modules that can help us with migrations most popular one I would say is the migrate module it

is the one that we will focus on mainly today but it is worth mentioning the feeds module which is also an alternative migrate module and feeds module work in different ways but you can do pretty much everything with both of them but they have very different

direction different approaches to the migration one to the task of doing a migration migrate module is really about migrating all the data from a an obsolete system that you really want to get rid of you get all the data out and you put it in your system leave

the old one behind the feeds module is more about synchronizing synchronizing data between an old environments and a new one it works well to do that and you can actually do a migration as a synchronization or you can do a synchronization as a migration but

it I think it's important to know what kind you're doing and if you want to do a synchronization maybe have a look at feeds if you want to do a migration look at the migrate module and this is the one that we're going to talk about today so no

matter which one you use migration always has three basic steps the first one is to get your data out of the old system then to do some processing of the data to make sure that it matches the format that you want to have and then you want to save that data

somewhere so you have a source some mappings and then you have a destination in our example of getting out of prison not the legal way first you dig a hole you get out then you have some transformation that's where most of the work happens crawling running

swimming as fast as possible and then you want to make sure that this stays oh it is so you change your identity something out of that not an expert in terms of doing this as an actual migration from an external source to a triple website for example we could

be importing from a CSV file or from a sequel database so first step is really to get the data the second step is to figure out how the old data will be mapped to the new data and then we actually want to save the we want to say the the note or the user or

anything that we want to save in the drupal system and here it's very interesting to see this separation because it makes it very clear why it's helpful to use a system like the migrate module we have sources we have destinations and we have the mapping

the sources it's generally something very common a CSV file a sequel database and API from some external system the destination it's also very common it's an entity it's a node it's a file it's something like this and the only part

that's really where business logic lies the thing that's really project specific is a step in the middle and when you use my grade module for example you can actually reuse an existing source in existing destination and just focus on the mapping part

so how does it work here's an example well actually the migrate module itself has a very good example module and it's an example that migrates beer that creates a beer nodes the thing though is that it only has three different kinds of beer and I don't

think that it is relevant and especially being in the Czech Republic we thought that you know three beers we've already had more than three different kinds of beer at the bar so we want to have something that's more relevant so we found a website that

documents czech beer and as you can see it's a beautiful websites modern web design fully responsive but it could use a migration so and so we what we did in this case we did a copy paste and we put this in a spreadsheet which we exported as CSV file this

was the only copy and pasting in step involves in this in this example and then we decided to create a module so the migrated module it is a module but it does not do any work for you so it does not declare any migrations it declares the tools and in order

to use my grade module you have to create your own module which will build on top of the manipulation my great framework so here this is just the info file nothing special about about this we depend on the migrated module and we have an include file which

which I'll get to in just a second so there's a module file the my module name module this one stays empty you don't need to have anything in there the migrated module well a migration really happens and it's a separate thing it does not happen

while your website is running its separate step so for this we have a separate include file the module named my grey tank and there we implement hook my great API there's two things that we need to define first the version of the API that want to use this

is pretty self-explanatory and then we want to define a list of the migrations that we want to do so one specific migration in this case would be I want to import content front of this type I want to import users I want to import a list of breweries for example

[ ... ]

Nota: se han omitido las otras 5.024 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.