Doctrine 1
  1. Doctrine 1
  2. DC-859

Diff generator doesn't load models from specified paths

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2, 1.2.3
    • Fix Version/s: None
    • Component/s: Migrations
    • Labels:
      None
    • Environment:
      WinXP, PHP 5.3.3

      Description

      Adding simple testcase, I have two version of PHP model, they differ in primary key.
      version 0 has: stateid = Integer (classic id number)
      version 1 has: stateid = char(2) (fixed length)

      After I run Doctrine_Core::generateMigrationsFromDiff, doctrine will load only the integer model and compare it, so no difference is detected and no migration script created.

      I'm attaching simple project where it doesn't work (adjust please LIBS_DIR definition for your setup).

      From current codepath I would say when YAML is used, the from/to classes get prefixes.
      When php model directories are used, the classes don't have have prefixes and their names are identical.
      I think this may be one part of problem.

      Trying to generate YAML files instead from php models lead to migration script dropping all tables. (looks like it's already reported as DC-755)
      I did call both yaml generation and diff tool in the same script, which doesn't work. When I generate schema in other script and call diff tool on schemas later, it works.

      Please, I'm willing to work on fix, but give me some ideas what should I try. (I thought about adding prefixes into php model files after they are copied into temp directory (to simulate YAML behavior), or bend the loading of models later, but I'm not sure the rest of code would cope with such fix, or there's more to do.

        Activity

        Hide
        Peter Helcmanovsky added a comment -

        Another potentional fix is to not copy model files into temp dir, but generate YAML from them, and then generate prefixed models trough YAML code path.
        Doesn't sound effective, but as long as YAML path will be fixed, it may work?

        Show
        Peter Helcmanovsky added a comment - Another potentional fix is to not copy model files into temp dir, but generate YAML from them, and then generate prefixed models trough YAML code path. Doesn't sound effective, but as long as YAML path will be fixed, it may work?
        Hide
        Peter Helcmanovsky added a comment - - edited

        One more idea for how it can be done ( ? ):
        to create temporary php script in temp dir together with from model files, run it, let it generate $fromInfo data, serialize them on disk, do the same with to models and get another serialized data, then load those files into $fromInfo and $toInfo and do the actual diffing.

        The point is that by running the small temporary script in new process it would be able to load model files from disk as classes without prefixing/changing them, create the $info data, and exit, so the newer classes with same name can be loaded again in the another new thread. The diff then has to live with serialized $info data only without loading model classes.

        Show
        Peter Helcmanovsky added a comment - - edited One more idea for how it can be done ( ? ): to create temporary php script in temp dir together with from model files, run it, let it generate $fromInfo data, serialize them on disk, do the same with to models and get another serialized data, then load those files into $fromInfo and $toInfo and do the actual diffing. The point is that by running the small temporary script in new process it would be able to load model files from disk as classes without prefixing/changing them, create the $info data, and exit, so the newer classes with same name can be loaded again in the another new thread. The diff then has to live with serialized $info data only without loading model classes.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Peter Helcmanovsky
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: