Manual:SQL patch file/pt-br

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Manual:SQL patch file and the translation is 13% complete.

Other languages:
English • ‎español • ‎français • ‎polski • ‎português • ‎português do Brasil • ‎日本語

You might write an SQL file either for a schema change in the core (see Development_policy#Database_patches, Manual:DatabaseUpdater.php ) or for an extension (see Manual:Hooks/LoadExtensionSchemaUpdates ). See also the general database coding conventions .

Exemplo

An SQL file to create a table might look something like this:

BEGIN;
 
CREATE TABLE /*_*/foo_bar(
-- Primary key
fb_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
-- user.user_id of the user who foobared the wiki
fb_user INT UNSIGNED NOT NULL,
-- user.user_text of the user who foobared the wiki
fb_user_text VARCHAR(255),
-- Timestamp of when the wiki was foobared
fb_timestamp varbinary(14) NOT NULL default NULL ''
)/*$wgDBTableOptions*/;

CREATE INDEX /*i*/fb_user ON /*_*/foo_bar (fb_user);
CREATE INDEX /*i*/fb_user_text ON /*_*/foo_bar (fb_user_text);
COMMIT;

Variable replacement

/*_*/ will be replaced with $wgDBprefix . /*i*/ will be replaced with an index prefix. /*$wgDBTableOptions*/ will be replaced with the value of $wgDBTableOptions . The first two need to be used in patch files, as in the example above. /*$wgDBTableOptions*/ is only used for MySQL database backends. There are other variable replacements but they are not used in practice. See the documentation of Database::replaceVars() for the full list.

Links externos