#=============================================================================
# Doloforge::Service::Sqlserver : add an MS SQL Server database for back-end use
#
# Generate config files from templates, add a config file to the whole, etc.
#
# Full help :
#   perldoc Doloforge::Service::Sqlserver
#=============================================================================


package Doloforge::Service::Sqlserver;

use strict;

# This base class implements the constructor and help methods in a generic way.
use base qw(Doloforge::Service);

use DBI;
use DBD::Pg;



#=============================================================================
=encoding utf8

=head1 NAME

Doloforge::Service::Sqlserver : Add an MS SQL Server database for back-end use

=head1 SYNOPSIS

    # Update the full configuration, running each client/project/service update
    doloforge config --update

=head1 DESCRIPTION

Todo

=cut


#=============================================================================
# Method update
#
# Create DB if it is configured but does not exist.
# This method receives :
#   option: context options passesd on the command-line (quite useless there)
#   client_conf: client configuration file contents (client.$name.yaml)
#   project_conf: project configuration file contents (project.$name.client.$name.yaml)
# This class does not (yet) create the DB for you...
# FIXME : create DB at project update

sub update {
    my $self = shift;

    my ($option, $client_conf, $project_conf) = @_;

    # Copy the service skeleton directory into the project shared directory.
    if ($self->has_role('nfs_role')) {                                                      # only create shared storage on the NFS server
        $self->skel_copy(
            "$self->{global}->{dir}->{skel}/service/shared/$self->{name}",                  # Skeleton directory to copy (skel/service/shared/[service]/)
            "$self->{global}->{dir}->{shared}/$client_conf->{name}/$project_conf->{name}",  # Where to copy it
            $self->{config}->{developerdirs},                                               # reference to the developers directories, that will have to be chown'ed to the following ownership
            ($client_conf->{uid} or $client_conf->{name}),                                  # user/group id of the client who owns this project. Developers of the same group will have write-access to files there.
            ($client_conf->{gid} or $client_conf->{name}),                                  # user/group id of the client who owns this project. Developers of the same group will have write-access to files there.
        );
    }
}



1;
__END__

=head1 AUTHOR

Nicolas Huillard <F<nicolas@huillard.net>>, Dolomède

=head1 SEE ALSO

doloforge(1)

=cut
