/[drupal]/contributions/modules/recipe/recipe.install
ViewVC logotype

Contents of /contributions/modules/recipe/recipe.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download) (as text)
Sun Apr 20 19:05:12 2008 UTC (19 months ago) by brdwor
Branch: MAIN
CVS Tags: DRUPAL-6--0-1, DRUPAL-6--1-0-BETA1, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.9: +143 -164 lines
File MIME type: text/x-php
Patch #227756 by shadow.  Initial 6.x compatability.
1 <?php
2 function recipe_schema() {
3 $schema['recipe'] = array(
4 'fields' => array(
5 'nid' => array(
6 'description' => t('The primary identifier for a recipe.'),
7 'type' => 'serial',
8 'unsigned' => TRUE,
9 'not null' => TRUE),
10 'source' => array(
11 'type' => 'varchar',
12 'not null' => FALSE,
13 'length' => 255),
14 'yield' => array(
15 'type' => 'int',
16 'unsigned' => FALSE,
17 'not null' => TRUE),
18 'instructions' => array(
19 'type' => 'text'),
20 'notes' => array(
21 'type' => 'text'),
22 'preptime' => array(
23 'type' => 'int',
24 'unsigned' => TRUE,
25 'default' => 0),
26 ),
27 'primary key' => array('nid'),
28 );
29 $schema['recipe_node_ingredient'] = array(
30 'description' => t('The base table for recipe ingredients.'),
31 'fields' => array(
32 'id' => array(
33 'description' => t('The primary identifier for a recipe ingredient.'),
34 'type' => 'serial',
35 'unsigned' => TRUE,
36 'not null' => TRUE),
37 'nid' => array(
38 'type' => 'int',
39 'unsigned' => TRUE,
40 'not null' => TRUE),
41 'unit_id' => array(
42 'type' => 'int',
43 'unsigned' => TRUE,
44 'not null' => TRUE),
45 'quantity' => array(
46 'type' => 'float',
47 'not null' => FALSE),
48 'ingredient_id' => array(
49 'type' => 'int',
50 'unsigned' => TRUE,
51 'not null' => TRUE),
52 ),
53 'primary key' => array('id'),
54 );
55 $schema['recipe_ingredient'] = array(
56 'description' => t('The base table for recipe ingredients.'),
57 'fields' => array(
58 'id' => array(
59 'description' => t('The primary identifier for a recipe ingredient.'),
60 'type' => 'serial',
61 'unsigned' => TRUE,
62 'not null' => TRUE),
63 'name' => array(
64 'type' => 'varchar',
65 'length' => 255),
66 'link' => array(
67 'type' => 'int',
68 'unsigned' => TRUE,
69 'not null' => TRUE),
70 ),
71 'primary key' => array('id'),
72 );
73 $schema['recipe_unit'] = array(
74 'description' => t('The base table for recipe units.'),
75 'fields' => array(
76 'id' => array(
77 'type' => 'serial',
78 'unsigned' => TRUE,
79 'not null' => TRUE),
80 'name' => array(
81 'type' => 'varchar',
82 'length' => 255),
83 'abbreviation' => array(
84 'type' => 'varchar',
85 'length' => 8),
86 'metric' => array(
87 'type' => 'int',
88 'not null' => TRUE,
89 'unsigned' => TRUE,
90 'default' => 0),
91 'type' => array(
92 'type' => 'varchar',
93 'length' => 6,
94 'not null' => TRUE,
95 'default' => 'Mass'),
96 ),
97 'primary key' => array('id'),
98 );
99
100 return $schema;
101 }
102 function recipe_install() {
103 drupal_install_schema('recipe');
104 recipe_populate_units();
105 }
106
107 function recipe_populate_units() {
108 $s = true;
109 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (1, 'Slice', 'sli', 0, 'Unit');");
110 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (2, 'Unit', '', 0, 'Unit');");
111 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (3, 'Clove', 'clv', 0, 'Unit');");
112 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (4, 'Pinch', 'pn', 0, 'Unit');");
113 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (5, 'Package', 'pk', 0, 'Unit');");
114 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (6, 'Can', 'cn', 0, 'Unit');");
115 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (7, 'Drop', 'dr', 0, 'Unit');");
116 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (8, 'Bunch', 'bn', 0, 'Unit');");
117 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (9, 'Dash', 'ds', 0, 'Unit');");
118 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (10, 'Carton', 'ct', 0, 'Unit');");
119 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (11, 'Cup', 'c', 0, 'Unit');");
120 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (12, 'Tablespoon', 'T', 0, 'Volume');");
121 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (13, 'Teaspoon', 't', 0, 'Volume');");
122 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (14, 'Pound', 'lb', 0, 'Mass');");
123 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (15, 'Ounce', 'oz', 0, 'Mass');");
124 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (16, 'Pint', 'pt', 0, 'Volume');");
125 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (17, 'Quart', 'q', 0, 'Volume');");
126 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (18, 'Gallon', 'gal', 0, 'Volume');");
127 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (19, 'Milligram', 'mg', 1, 'Mass');");
128 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (20, 'Centigram', 'cg', 1, 'Mass');");
129 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (21, 'Gram', 'g', 1, 'Mass');");
130 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (22, 'Kilogram', 'kg', 1, 'Mass');");
131 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (23, 'Millilitre', 'ml', 1, 'Volume');");
132 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (24, 'Centilitre', 'cl', 1, 'Volume');");
133 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (25, 'Litre', 'l', 1, 'Volume');");
134 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (26, 'Decilitre', 'dl', 1, 'Volume');");
135 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (27, 'Tablespoon (Metric)', 'tbsp', 1, 'Volume');");
136 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (28, 'Teaspoon (Metric)', 'tsp', 1, 'Volume');");
137 $s = $s && db_query("INSERT INTO {recipe_unit} VALUES (29, 'Unknown', '', 0, 'Unit');");
138 return $s;
139 }
140
141 function recipe_uninstall() {
142 drupal_uninstall_schema('recipe');
143 }

  ViewVC Help
Powered by ViewVC 1.1.2