1

I have a project where we have a legacy system built in Drupal 6 that has been heavily customized, with much of the data stored in custom tables. We are currently planning a D6 to D7 upgrade, but we have an immediate need to access that data in a Drupal 7 instance, leaving the D6 site intact for now.

I would like to access that data using Drupal Entities and wrap each D6 table in a Drupal 7 Entity; however I'm having trouble making that work since the underlying assumption with the Entity API is that the data is stored in the local database, and this database is remote. We can access the database directly from the Drupal 7 instance, and I have the database credentials loaded in settings.php. I can query the data using Database::getConnection('default', 'legacy')->select(), so I know my connection is good; however I have no idea how to go about structuring an Entity class so that I can leverage EFQ, Views, etc. on this data.

I looked at Remote Entity API, but I"m not dealing with a RESTful service here, I have a direct connection to the D6 database.

Any assistance or hints would be greatly appreciated. I've worn Google out.

  • Drupal 6 and Drupal 7 data is heavily incompatible. Either you will have to practically rewrite entities from the ground up, or give up this idea, and follow classic solutions: 1) Migrate content to new site or 2) Start RESTful server on Drupal 6, and let it continue to handle your data. – Mołot Oct 8 '14 at 12:01
  • @Mołot Luckily enough, someone's already done it – Clive Oct 8 '14 at 12:06
  • @Clive OP already said "I looked at Remote Entity API, but" – Mołot Oct 8 '14 at 12:17
  • Lisa, the question "Any assistance or hints" is a bit broad, but you can override an entities load function to fetch the data from anywhere you want, including a second database with custom content. I'd be happy to discuss the topic further in the chat – Letharion Oct 17 '14 at 6:37
0

As I understand it you're discounting the Remote Entity API module because you don't have a RESTful service...

The module actually relies on the Web Service Clients module, which provides that REST service for you:

Parallel to the Services module, the Clients module provides the ability to implement pluggable clients to external web services, including external Drupal sites running the Services module, the main use case being connecting to other Drupal installs via the Services module with either the REST or XMLRPC server.

Clients module allows you to create connections to remote services with an admin UI. These handle fetching a result from a remote service. Different types of connection are provided for different types of services. There is a Drupal client connection type for different versions of Services (5.x-0.92, 6.x-2.x, 7.x-3.x), hence Clients can be used to connect to sites with different versions of Drupal.

Emphasis mine.

  • OP already said "I looked at Remote Entity API, but". Seems she already tried this solution and does not want it; prefers direct database connection. – Mołot Oct 8 '14 at 12:18
  • @Mołot but I"m not dealing with a RESTful service here, I have a direct connection to the D6 database. suggests to me the OP is discounting solutions on false information - using this module you have an implicit RESTful connection. Unless there's another hidden gem of a module which magically exposes remote db connections as local ones, the only alternative I can think of is "write it from scratch". – Clive Oct 8 '14 at 12:21
  • Oh, if you're right, then good. I understood it more like she wanted to discard soon-unsupported d6 and use it's DB directly with 7. – Mołot Oct 8 '14 at 12:23
  • 1
    Yeah you may well be right, I could easily have got that wrong. But as your first comment on the question rightly alludes to, to make this happen you need some sort of translation layer between D6 and D7 data. REST feels like an infinitely better option than actually coding that layer as D6 CCK -> D7 fields – Clive Oct 8 '14 at 12:25
  • Explain to me why I would need the Clients module. I'm not dealing with a REST api, I have a direct database connection. I simply want to query the remote legacy database instead of the local database. Right now the legacy system continues to live and is being used on a daily basis, so migrating the data to D7 is not currently an option. So, I'm failing to see where the Clients module has any role here, please enlighten me. I can use the Database functions in Drupal 7 to do this, but I would prefer to leverage the Entity API if possible so that I can in turn leverage Views. – Lisa Ridley Oct 8 '14 at 13:11
0

If it was me I would properly migrate the data from the old database into Drupal 7.

I would plan out the entities in the new site that will take the data from the old site. They may be nodes, custom entities, data module tables, users, taxonomy terms, etc.

Then I would migrate the data from the old database into those native Drupal 7 entities.

Then I would completely do away with the old legacy database.

By hanging on to the old database and somehow hacking it into your new website you are adding much unnecessary complexity and it will likely cause you lots of headaches in future.

As for the migration, I would use the Migrate module, the Migrate extras module and depending on your needs maybe the Drupal-to-Drupal data migration module.

The migrate module is fairly complex and has a bit of a learning curve but is very powerful. It follows consistent patterns though so once you've learned it it's not so scary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.