@@ -11,10 +11,10 @@ Defines the primary key for the table. Primary keys uniquely identify each row a
1111``` php
1212use StellarWP\Schema\Indexes\Primary_Key;
1313
14- // Single column primary key
14+ // Single column primary key.
1515$indexes[] = new Primary_Key( [ 'id' ] );
1616
17- // Composite primary key
17+ // Composite primary key.
1818$indexes[] = new Primary_Key( [ 'event_id', 'ticket_id' ] );
1919```
2020
@@ -25,10 +25,10 @@ Ensures that all values in the indexed columns are unique across the table.
2525``` php
2626use StellarWP\Schema\Indexes\Unique_Key;
2727
28- // Single column unique constraint
28+ // Single column unique constraint.
2929$indexes[] = new Unique_Key( [ 'email' ] );
3030
31- // Composite unique constraint
31+ // Composite unique constraint.
3232$indexes[] = new Unique_Key( [ 'user_id', 'event_id' ] );
3333```
3434
@@ -39,10 +39,10 @@ A standard index that speeds up lookups on the specified columns. Does not enfor
3939``` php
4040use StellarWP\Schema\Indexes\Classic_Index;
4141
42- // Single column index
42+ // Single column index.
4343$indexes[] = new Classic_Index( [ 'status' ] );
4444
45- // Composite index
45+ // Composite index.
4646$indexes[] = new Classic_Index( [ 'user_id', 'created_at' ] );
4747```
4848
@@ -53,10 +53,10 @@ Enables full-text searching on text columns. Useful for content search functiona
5353``` php
5454use StellarWP\Schema\Indexes\Fulltext_Index;
5555
56- // Single column fulltext
56+ // Single column fulltext.
5757$indexes[] = new Fulltext_Index( [ 'content' ] );
5858
59- // Multiple columns fulltext
59+ // Multiple columns fulltext.
6060$indexes[] = new Fulltext_Index( [ 'title', 'content', 'excerpt' ] );
6161```
6262
@@ -103,10 +103,10 @@ The library automatically generates index names based on the index type and colu
103103All index types support multiple columns (composite indexes):
104104
105105``` php
106- // Composite classic index
106+ // Composite classic index.
107107$indexes[] = new Classic_Index( [ 'user_id', 'status', 'created_at' ] );
108108
109- // Composite unique key
109+ // Composite unique key.
110110$indexes[] = new Unique_Key( [ 'external_id', 'source' ] );
111111```
112112
@@ -145,22 +145,22 @@ public static function get_schema_history(): array {
145145
146146 $columns[] = new Created_At( 'created_at' );
147147
148- // Indexes for common queries
148+ // Indexes for common queries.
149149 $indexes = new Index_Collection();
150150
151- // Unique order numbers
151+ // Unique order numbers.
152152 $indexes[] = new Unique_Key( [ 'order_number' ] );
153153
154- // Fast lookups by customer
154+ // Fast lookups by customer.
155155 $indexes[] = new Classic_Index( [ 'customer_id' ] );
156156
157- // Fast lookups by status
157+ // Fast lookups by status.
158158 $indexes[] = new Classic_Index( [ 'status' ] );
159159
160- // Efficient date range queries
160+ // Efficient date range queries.
161161 $indexes[] = new Classic_Index( [ 'created_at' ] );
162162
163- // Composite index for customer orders by status
163+ // Composite index for customer orders by status.
164164 $indexes[] = new Classic_Index( [ 'customer_id', 'status' ] );
165165
166166 return new Table_Schema( $table_name, $columns, $indexes );
@@ -199,13 +199,13 @@ public static function get_schema_history(): array {
199199
200200 $indexes = new Index_Collection();
201201
202- // Unique slugs for URL routing
202+ // Unique slugs for URL routing.
203203 $indexes[] = new Unique_Key( [ 'slug' ] );
204204
205- // Full-text search on title and content
205+ // Full-text search on title and content.
206206 $indexes[] = new Fulltext_Index( [ 'title', 'content' ] );
207207
208- // Fast filtering by status
208+ // Fast filtering by status.
209209 $indexes[] = new Classic_Index( [ 'status' ] );
210210
211211 return new Table_Schema( $table_name, $columns, $indexes );
@@ -224,7 +224,7 @@ public static function get_schema_history(): array {
224224 '1.0.0' => function() use ( $table_name ) {
225225 $columns = new Column_Collection();
226226
227- // Using session_id as primary key (not auto-increment)
227+ // Using session_id as primary key (not auto-increment).
228228 $columns[] = ( new String_Column( 'session_id' ) )
229229 ->set_type( Column_Types::VARCHAR )
230230 ->set_length( 128 );
@@ -241,13 +241,13 @@ public static function get_schema_history(): array {
241241
242242 $indexes = new Index_Collection();
243243
244- // String-based primary key
244+ // String-based primary key.
245245 $indexes[] = new Primary_Key( [ 'session_id' ] );
246246
247- // Lookup sessions by user
247+ // Lookup sessions by user.
248248 $indexes[] = new Classic_Index( [ 'user_id' ] );
249249
250- // Efficiently clean up expired sessions
250+ // Efficiently clean up expired sessions.
251251 $indexes[] = new Classic_Index( [ 'expires_at' ] );
252252
253253 return new Table_Schema( $table_name, $columns, $indexes );
@@ -276,10 +276,10 @@ public static function get_schema_history(): array {
276276
277277 $indexes = new Index_Collection();
278278
279- // Composite primary key (no auto-increment needed)
279+ // Composite primary key (no auto-increment needed).
280280 $indexes[] = new Primary_Key( [ 'event_id', 'venue_id' ] );
281281
282- // Fast reverse lookups
282+ // Fast reverse lookups.
283283 $indexes[] = new Classic_Index( [ 'venue_id' ] );
284284
285285 return new Table_Schema( $table_name, $columns, $indexes );
@@ -313,11 +313,11 @@ public static function get_schema_history(): array {
3133133 . ** Cover common queries** : Design indexes around your most frequent query patterns
314314
315315``` php
316- // Good: User queries often filter by status first, then date
316+ // Good: User queries often filter by status first, then date.
317317$indexes[] = new Classic_Index( [ 'status', 'created_at' ] );
318318
319- // Also good: Allows queries on just 'status' OR 'status' + 'created_at'
320- // MySQL can use the leftmost prefix
319+ // Also good: Allows queries on just 'status' OR 'status' + 'created_at'.
320+ // MySQL can use the leftmost prefix.
321321```
322322
323323### Performance Considerations
@@ -336,7 +336,7 @@ public static function get_schema_history(): array {
336336
337337 return [
338338 '1.0.0' => function() use ( $table_name ) {
339- // Original schema
339+ // Original schema.
340340 $columns = new Column_Collection();
341341 $columns[] = ( new ID( 'id' ) )->set_auto_increment( true );
342342 $columns[] = ( new String_Column( 'email' ) )
@@ -346,7 +346,7 @@ public static function get_schema_history(): array {
346346 return new Table_Schema( $table_name, $columns );
347347 },
348348 '1.1.0' => function() use ( $table_name ) {
349- // Add unique constraint on email in version 1.1.0
349+ // Add unique constraint on email in version 1.1.0.
350350 $columns = new Column_Collection();
351351 $columns[] = ( new ID( 'id' ) )->set_auto_increment( true );
352352 $columns[] = ( new String_Column( 'email' ) )
0 commit comments