cakephp / api_generator

[Unmaintained] Official CakePHP API Generator Git Repository
113 stars 31 forks source link

initdb making wrong schema call? #10

Open ghost opened 11 years ago

ghost commented 11 years ago

Created by Kevin van Zonneveld, 22nd Sep 2010. (originally Lighthouse ticket #30):


Hi guys.

Just tried out api_generator but couldn't get it to work.
When running:

[kevin`@dev` /app/cakephp/cake/console (master +)]$ ./cake api_index initdb

I get:

Welcome to CakePHP v1.2.6 Console
---------------------------------------------------------------
App : app
Path: /app/cakephp/app
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------
The Schema Shell generates a schema object from
the database and updates the database from the schema.
---------------------------------------------------------------
Usage: cake schema <command> <arg1> <arg2>...
---------------------------------------------------------------
Params:

    -connection <config>
        set db config <config>. uses 'default' if none is specified

    -path <dir>
        path <dir> to read and write schema.php.
        default path: /app/cakephp/app/config/sql

    -name <name>
        classname to use.

    -file <name>
        file <name> to read and write.
        default file: api_generator.php

    -s <number>
        snapshot <number> to use for run.

    -dry
        Perform a dry run on 'run' commands.
        Queries will be output to window instead of executed.

    -f
        force 'generate' to create a new schema.
Commands:

    schema help
        shows this help message.

    schema view
        read and output contents of schema file

    schema generate
        reads from 'connection' writes to 'path'
        To force generation of all tables into the schema, use the -f param.
        Use 'schema generate snapshot <number>' to generate snapshots
        which you can use with the -s parameter in the other operations.

    schema dump <filename>
        Dump database sql based on schema file to <filename>. 
        If <filename> is write, schema dump will be written to a file
        that has the same name as the app directory.

    schema run create <schema> <table>
        Drop and create tables based on schema file
        optional <schema> arg for selecting schema name
        optional <table> arg for creating only one table
        pass the -s param with a number to use a snapshot
        To see the changes, perform a dry run with the -dry param

    schema run update <schema> <table>
        alter tables based on schema file
        optional <schema> arg for selecting schema name.
        optional <table> arg for altering only one table.
        To use a snapshot, pass the -s param with the snapshot number
        To see the changes, perform a dry run with the -dry param

Looks like it's making an invalid call to schema?
I'm using Cake 1.2.6 and checked out master of http://github.com/cakephp/api_generator in app/plugins/(api_generator)

When I run:

./cake api_index

I do get a valid shell:

Api Generator Class Index Generation
---------------------------------------------------------------
Available commands:
  initdb
    Create the schema used for the Api Generator Plugin
  showfiles
    Show the list of files that will be parsed for classes based on your configuration.
    Use to check if your config is going to parse the files you want.
  update
    Clear the existing class index and regenerate it.
  set_routes
    Add routes for Api generator to your routes file.
  users
    View list of users, and create new ones.
ghost commented 11 years ago

22nd Sep 2010, Courtney Wilburn said:


I had the same issue the other day, and I'm using 1.2.7. It appears that initdb runs "schema create" (cake 1.3 syntax) instead of "schema run create," (cake 1.2.x syntax). I ended up changing my /vendors/shells/api_index.php file to use the cake 1.2.x syntax in the initdb function. I was able to run initdb and the other commands without issue, but then ran into a few other version-related syntax errors when trying to view the generated docs.

ghost commented 11 years ago

23rd Sep 2010, Kevin van Zonneveld said:


Ok looks like that could get pretty hairy then. What's weird is that the github readme said it was compatible with 1.2. That's basically why I gave it a shot.

Is there a commit hash that's compatible with 1.2? Then I'll just skip on the new features and checkout that version. Can't upgrade my app to 1.3 yet cause it's pretty huge.

ghost commented 11 years ago

23rd Sep 2010, Courtney Wilburn said:


I tried finding a commit hash that was 1.2 compatible, but I couldn't find one (I'm sure there is one). I can't upgrade my either for the same reason. Most of the syntax errors were related to the changes in the HTML helper and were easy to fix, but a bit of a headache to have to hunt for. Searching for a compatible commit hash would probably be a better use of your time.

ghost commented 11 years ago

24th Sep 2010, Kevin van Zonneveld said:


Did this:

[kevin`@dev` /app/plugins/api_generator (1.2)]$ git checkout -b 1.2 734bc10

Initdb & update now work but I had to explicitly set extensions in the configuration .ini:

[file]
extensions = php,ctp
ghost commented 11 years ago

27th Sep 2010, Mark Story said:


The 0.3-branch and 0.3 tag should be compatible with CakePHP 1.2