Last updated May 31, 2011. Created on December 7, 2009.
Edited by annahlauren, _rune, Jakob Stoeck, aenw. Log in to edit this page.

This handbook page is part of the documentation for the Auto Admin module.

The Auto Admin drush command inspects the database schema and generates or updates [MODULE].install and/or [MODULE].autoadmin.inc files in the /modules/[MODULE] directory.

Getting started

To use autoadmin from the command line you need to have the drush project installed. The "drush" command also needs to be on your executable path. You can test this by changing to a directory inside your drupal project and running the following drush command: drush status. You should see output similar to the following if drush is working correctly:

$ drush status
  PHP configuration : /etc/php5/cli/php.ini
  Drupal Root       : /home/rune/workspace-light/drupal-autoadmin
  Drupal version    : 6.14
  Site Path         : sites/default
  Site URI          : http://default
  Database Driver   : mysqli
  Database Hostname : localhost
  Database Username : root
  Database Name     : drupal-autoadmin
  Database Password : passwd
  Database          : Connected
  Drupal Bootstrap  : Successful
  Drupal User       : Anonymous

You can find information about how to install drush in its README.txt file.

Be aware that the module you are generating files for needs to be enabled before running any "drush autoadmin-***" commands. For a fast way to create module files and hook functions from the command line, check out the excellent Module Builder module.

After successful creation of those files your content will be available under www.example.org/admin/content/YOUR_TABLE_NAME.

Getting help

Get an overview of all available drush autoadmin-*** commands by typing "drush help autoadmin". You should see output like this:

$ drush help autoadmin
-------------------------
-- Auto Admin Commands --
-------------------------
autoadmin-generate                  Generates both .install file and Auto Admin schema.
autoadmin-update                    Updates both .install file and Auto Admin schema.
autoadmin-generate-schema           Generate schema.
autoadmin-update-schema             Update schema.
autoadmin-generate-install          Generates .install file.
autoadmin-update-install            Update hook_schema() in .install file.

Use ie. 'drush help autoadmin-generate' to get help for each command.

Get detailed information for each command by typing "drush help autoadmin [SUBCOMMAND]". An example would be:

$ drush help autoadmin-generate
Generates both .install file and Auto Admin schema.

Arguments:
[MODULE] [table1] [table2] ... [tableN]   First the module, and then all tables to be generated

Options:
-w, --write                               Write to [MODULE]/[MODULE].autoadmin.inc  
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation

Description of all commands

Here are short examples for each of the six Auto Admin drush commands. Each example shows a command with an explanation, and then the help output for the command. Please note that "schema" means the Auto Admin schema located in the "[MODULE].autoadmin.inc" file, and "install" means the installation schema located in the "[MODULE].install" file. These two are merged internally and make up the complete schema used for generating the administration pages.

Also be aware of the output options for the Auto Admin drush commands. If no options are specified, output is sent to stdout (usually this is the screen). The "-w" option will write all output to files into the modules/[MODULE] directory (e.g. the "[MODULE].autoadmin.inc" file, and/or the "[MODULE].install" file). The examples below show use of the "-w" option.

drush -w autoadmin-generate Creates new versions of install and schema files and writes them to "[MODULE].install" and "[MODULE].autoadmin.inc" in the modules/[MODULE] directory. After this command is run you would normally modify "[MODULE].autoadmin.inc" to your liking. (Leave out the “-w” option to have the output sent to stdout; also use “-y” to overwrite the files without confirmation; use “-n” for no output.)

$ drush help autoadmin-generate
Generates both .install file and Auto Admin schema.

Arguments:
[module] [table1] [table2] ... [tableN]   First the module, and then all tables to be generated

Options:
-w, --write                               Write to [MODULE]/[MODULE].autoadmin.inc  
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation

drush -w autoadmin-update Updates the current install ("[MODULE].install") and schema ("[MODULE].autoadmin.inc") files. It tries to merge as much as possible from the existing files, namely the "title", "title_plural" and "description" keys. (Leave out the “-w” option to have the output sent to stdout; also use “-y” to overwrite the files without confirmation; use “-n” for no output.)

$ drush help autoadmin-update
Updates both .install file and Auto Admin schema.

Arguments:
[module] [table1] [table2] ... [tableN]   First the module, and then all tables to be updated

Options:
-w, --write                               Write to [MODULE]/[MODULE].autoadmin.inc  
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation
-t, --tables                              Tables to add

drush -w autoadmin-generate-schema The same as "drush -w autoadmin-generate", but it only generates the "[MODULE].autoadmin.inc" file.

$ drush help autoadmin-generate-schema
Generate schema.

Arguments:
[module1] [module2] ... [moduleN]         Modules selected for schema generation

Options:
-w, --write                               Write to [MODULE]/[MODULE].autoadmin.inc  
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation

drush -w autoadmin-update-schema The same as "drush -w autoadmin-update", but it only updates the "[MODULE].autoadmin.inc" file.

$ drush help autoadmin-update-schema
Update schema.

Arguments:
[module1] [module2] ... [moduleN]         Modules selected for schema update

Options:
-w, --write                               Write to [MODULE]/[MODULE].autoadmin.inc  
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation

drush -w autoadmin-generate-install The same as "drush -w autoadmin-generate", but it only generates the "[MODULE].install" file.

$ drush help autoadmin-generate-install
Generates .install file.

Arguments:
[module] [table1] [table2] ... [tableN]   First the module, and then all tables to be added

Options:
-w, --write                               Write to [MODULE]/[MODULE].install        
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation

drush -w autoadmin-update-install The same as "drush -w autoadmin-update", but it only updates the "[MODULE].install" file.

$ drush help autoadmin-update-install
Update hook_schema() in .install file.

Arguments:
[module] [table1] [table2] ... [tableN]   First the module, and then all tables to be added. No longer existing tables are removed automatically

Options:
-w, --write                               Write to [MODULE]/[MODULE].install        
-n, --no-output                           Do not dump to stdout                     
-y, --yes                                 Files are overwritten without confirmation

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

aenw’s picture

This page should be updated so that all example include the "-w" option, since that is required for output to be written to the files (vs. stdout).
When I first ran autoadmin, based on what I read here, I was confused as to why nothing was being written to .inc or .install files anywhere. I found my answer by looking at the code for autoadmin_drush_output_file($module, $file_name, $content).
It would also be helpful if there is mention about where the files will be (e.g. they will be written to the /[MODULE] subdirectory). That way new users will know where to look for them, or that something is wrong if they're not there.
I'm happy to update this page if it's helpful. (I can create a draft and then someone else can review it if that's the best approach.)

_rune’s picture

Even though "-w, --write Write to [MODULE]/[MODULE].autoadmin.inc" is mentioned for every command I think you are right that this is something a new user of Auto Admin could miss. I you feel like editing this page and/or creating a FAQ page that would be great, just go ahead and do so directly on the page.

Thx!
Rune

shaneforsythe’s picture

Can this be used to make simple crud interface for Content types using cck? I tried

drush autoadmin-generate content content_type_event -w

but attempted to write to /site/all/modules/content instead of /modules/content/

_rune’s picture

No at the moment, it only supports "sites/all/modules/xxx" fully. It should be possible to move the files manually though.

dparizek’s picture

will not work with newer versions of drush, but I downgraded back to 4.6 and working now.

_________________________
Dave Parizek
Land Rover Geek

dparizek’s picture

hmm, well got it to at least print out help on the autoadmin commands, by switching to drush 4.6, but still cannot get any of the commands to actually work

_________________________
Dave Parizek
Land Rover Geek