=head1 NAME

bif-doc-func-new-project - add a new project to an change

=head1 VERSION

0.1.5_3 (2015-06-30)

=head1 SYNOPSIS

=for bifcode #!sqlite

    BEGIN;

    INSERT INTO changes(...);

    INSERT INTO func_new_project(
        change_id,  -- integer NOT NULL,
        id,         -- integer NOT NULL,
        parent_id,  -- integer,
        name,       -- varchar(40),
        title       -- varchar(1024) NOT NULL DEFAULT ''
    ) VALUES (...);

    INSERT INTO func_new_project_status(...);

    INSERT INTO func_update_project(...);

    INSERT INTO func_merge_changes(...);

    COMMIT;

=head1 DESCRIPTION

The func_new_project() function creates a new project in the repository
against an in-progress change #1 by taking the following actions:

=over

=item * A row is inserted into the F<topics> table with a SHA1 hash of
the values resulting in the project/topic UUID.

=item * A row is inserted into the F<projects> table.

=item * Change #2 is started by inserting a new row into the
F<changes> table.

=item * A row is inserted into F<hub_deltas> against change #2 for the
local hub with project_id set to topics.id / projects.id, which kicks
of the following trigger actions:

=over

=item * A row is inserted into F<hub_related_projects> connecting the
project to the local hub.

=item * A row is inserted into F<hub_related_changes> connecting the
change to the local hub, which kicks off the following trigger actions:

=over

=item * A row is inserted into hub_related_changes_merkle taking into account the new
change #2.

=back

=item * A row is inserted into F<hubs_tomerge> but probably keeps zero
values.

=back

=item * A row is inserted into F<project_deltas> against change #1, which kicks off the
following trigger actions:

=over

=item * A row is inserted into F<projects_tomerge>.

=item * A row is inserted into F<project_related_changes> connecting
change #1 to the project, which kicks off the following trigger
actions:

=over

=item * A row is inserted into project_related_changes_merkle taking into account the new
change #1.

=back


=item * If project_delta.hub_uuid exists in the repository then every
project-only change from F<project_related_changes> is added to 
F<hub_related_changes> 

=back

=back

The enclosing transaction will fail with a foreign key violation unless
at least one call to
L<func_new_project_status()|bif-doc-func-new-project-status> is also
made and a row is inserted into
L<project_deltas|bif-doc-table-project-changes> resulting in
C<projects.project_status_id> containing a valid foreign key value into
the L<project_status|bif-doc-table-project-status> table.

=head1 SEE ALSO

L<bif-doc-table-changes>, L<bif-doc-table-topics>,
L<bif-doc-table-projects>, L<bif-doc-func-new-project-status>,
L<bif-doc-table-project-changes>, L<bif-doc-func-merge-changes>

=head1 AUTHOR

Mark Lawrence E<lt>nomad@null.netE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2013-2015 Mark Lawrence <nomad@null.net>

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

